//C++ program using class
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class Student
{
private:
int rollno;
ch...
cout<<"n 1. Specific student";
cout<<"n 2. Topper";
cout<<"n 3. Exit ";
cout<<"n Enter your choice";
cin>> choice;
switch(...
Upcoming SlideShare
Loading in …5
×

C++ program using class

2,630 views
2,246 views

Published on

This is for the students of computer science for their projects

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,630
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
43
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

C++ program using class

  1. 1. //C++ program using class #include<iostream.h> #include<stdio.h> #include<conio.h> class Student { private: int rollno; char name[25]; float marks; char grade; public: void readStudent() { cout<<"n Enter Roll no.:"; cin>> rollno; cout<<"n Enter name :"; gets(name); cout<<"n Enter marks :" ; cin>> marks; } void dispStudent() { calcGrade(); cout<<"n Roll no. : "<<rollno; cout<<"n Name :"<<name; cout<<"n Marks :"<<marks; cout<<"n Grade :"; } int getRollno() { return rollno; } float getMarks() { return marks; } void calcGrade() { if (marks>=75) grade='0'; else if (marks >=60) grade = 'A'; else if (marks >=50) grade='B'; else if (marks >=40) grade ='C'; else grade= 'F'; } }; void main() {Student XIIa[10]; for(int i=0; i<10; ++i) { cout<<"n Enter the details of student"<<i+1<<":"; XIIa[i].readStudent(); } int choice, rno, pos=-1, highmarks=0; do { clrscr(); cout<<"nnn Main menunn";
  2. 2. cout<<"n 1. Specific student"; cout<<"n 2. Topper"; cout<<"n 3. Exit "; cout<<"n Enter your choice"; cin>> choice; switch(choice) { case 1: cout<<"n Enter roll no. of student whose details you want to see:"; cin>>rno; for(i=0; i<10; ++i) { if (XIIa[i].getRollno()==rno) {XIIa[i].dispStudent(); break; } } if (i==10) cout<<"n INVALID ROLLNO.!!!!!!!!"; getch(); break; case 2: for( i=0; i<10; ++i) { if(XIIa[i].getMarks()>highmarks) { pos=i; highmarks=XIIa[i].getMarks(); } } XIIa[pos].dispStudent(); getch(); break; case 3: break; default: cout<<"n nnnnn WRONG CHOICE!!!!!!!!!!!!!nnnnnnn"; } } while(choice>=1&& choice <3); }

×