Can you help rectify two errors in the following program:
1. Statement missing ;
2. Declaration terminated incorrectly
1. Statement missing ;
2. Declaration terminated incorrectly
Code:
#include<iostream.h> #include<stdio.h> #include<conio.h> class student { int rollno; char name[25]; char grade; float marks; public: void readstudent() { cout<<"Enter the rollno.:"; cin>>rollno; cout<<"\nEnter the name:"; gets(name); cout<<"\nEnter the marks:"; cin>>marks; } void disstudent() { cgrade(); cout<<"\nRollno:"<<rollno; cout<<"\nName:"<<name; cout<<"\nMArks:"<<marks; cout<<"\nGrade:"<<grade; } int getrollno() { return rollno; } float getmarks() { return marks; } void cgrade() { if(marks>=75) { grade='O'; } else if(marks>=60) { grade='A'; } else (marks>=40) { grade='F'; } } void main() { clrscr(); student s[3]; for (int i=0;i<3; i++) { cout<<"Enter details of student"<<i+1<<":"; s[i].readstudent(); } int ch,rno,pos=-1,highmarks=0; do{ cout<<"Main Menu \n 1.Specific student\n 2.Topper\n 3.Exit \n Enter the choice:\n"; cin>>ch; switch(ch) { case 1: cout<<"Enter the rollno:\n"; cin>>rno; for(int i=0;i<3;i++) { if (s[i].getrollno()==rno) { s[i].disstudent(); break; } } if(i==10) { cout<<"Invalid"; } case 2: for(i=0;i<3;i++) { if (s[i].getmarks()>highmarks) { pos=i; highmarks=s[i].getmarks(); } } s[i].disstudent(); break; case 3: break; default: cout<<"Wrong"; break; } } while(ch>=1&&ch<3); getch(); } }
Comment