By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

Error rectification

P: 1
Can you help rectify two errors in the following program:
1. Statement missing ;
2. Declaration terminated incorrectly

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<stdio.h>
  3. #include<conio.h>
  4. class student
  5. {
  6.  int rollno;
  7.  char name[25];
  8.  char grade;
  9.  float marks;
  10.  public: void readstudent()
  11.  
  12.  {
  13.   cout<<"Enter the rollno.:";
  14.   cin>>rollno;
  15.   cout<<"\nEnter the name:";
  16.   gets(name);
  17.   cout<<"\nEnter the marks:";
  18.   cin>>marks;
  19.   }
  20.    void disstudent()
  21.    {
  22.     cgrade();
  23.     cout<<"\nRollno:"<<rollno;
  24.     cout<<"\nName:"<<name;
  25.     cout<<"\nMArks:"<<marks;
  26.     cout<<"\nGrade:"<<grade;
  27.     }
  28.     int getrollno()
  29.     {
  30.      return rollno;
  31.      }
  32.     float getmarks()
  33.     {
  34.      return marks;
  35.      }
  36.     void cgrade()
  37.     {
  38.      if(marks>=75)
  39.      {
  40.       grade='O';
  41.       }
  42.      else if(marks>=60)
  43.      {
  44.       grade='A';
  45.       }
  46.      else (marks>=40)
  47.      {
  48.       grade='F';
  49.       }
  50.       }
  51.  
  52.    void main()
  53.    {
  54.     clrscr();
  55.     student s[3];
  56.     for (int i=0;i<3; i++)
  57.     {
  58.      cout<<"Enter details of student"<<i+1<<":";
  59.      s[i].readstudent();
  60.      }
  61.       int ch,rno,pos=-1,highmarks=0;
  62.       do{
  63.      cout<<"Main Menu \n 1.Specific student\n 2.Topper\n 3.Exit \n Enter the choice:\n";
  64.      cin>>ch;
  65.      switch(ch)
  66.      {
  67.       case 1: cout<<"Enter the rollno:\n";
  68.       cin>>rno;
  69.       for(int i=0;i<3;i++)
  70.       {
  71.        if (s[i].getrollno()==rno)
  72.        {
  73.         s[i].disstudent();
  74.         break;
  75.         }
  76.        }
  77.         if(i==10)
  78.         {
  79.          cout<<"Invalid";
  80.          }
  81.       case 2: for(i=0;i<3;i++)
  82.       {
  83.        if (s[i].getmarks()>highmarks)
  84.         {
  85.          pos=i;
  86.          highmarks=s[i].getmarks();
  87.          }
  88.         }
  89.          s[i].disstudent();
  90.          break;
  91.       case 3: break;
  92.       default: cout<<"Wrong";
  93.       break;
  94.      }
  95.     }
  96.      while(ch>=1&&ch<3);
  97.      getch();
  98.     }
  99.  }
  100.  
Sep 5 '16 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
You have mismatched braces. It looks like the main() is inside the class definition. There's one place where you have
"if (i == 10)" but there is no i variable defined.

The class definition does not end with a ;.
Sep 6 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.