/* C++ Classes and Objects - Example Program */ #include #include #include #include class STUDENT { private: int rollno; char name[40]; float marks; char grade; public: void read() // mutator { cout<<"\nEnter rollno: "; cin>>rollno; cout<<"Enter name: "; gets(name); cout<<"Enter marks: "; cin>>marks; } void display() // accessor { calculategrade(); cout<<"Roll no.: "<=80) { grade = 'A'; } else if(marks>=60) { grade = 'B'; } else if(marks>=40) { grade = 'C'; } else { grade = 'F'; } } }; void main() { clrscr(); STUDENT tw[5]; for(int i=0; i<5; i++) { cout<<"\nEnter details for Student "<>choice; switch(choice) { case 1: cout<<"Enter roll no of student whose details you want to know/see: "; cin>>rno; for(i=0; i<5; i++) { if(tw[i].getrollno()==rno) { tw[i].display(); break; } } if(i==5) { cout<<"Invalid rollno..!!"; } break; case 2: for(i=0; i<5; i++) { if(tw[i].getmarks()>highmarks) { pos=i; highmarks=tw[i].getmarks(); } } tw[pos].display(); break; case 3: cout<<"Exiting..press a key.."; getch(); exit(1); default: cout<<"Wrong choice..!!"; break; } }while(choice>=1 && choice<=3); getch(); }