Sunday, March 21, 2010

A Program to find the grade of a student in C++


main()
{
 struct student
 {
  int reg_no,m1,m2,m3,total,avg;
  char *name;
 }stud[10];
 int i;
 clrscr();
 for(i=1;i<=1;i++)
 {
  cout<<"\nENTER THE REG_NO,NAME,M1,M2,M3 : ";
  cin>>stud[i].reg_no>>stud[i].name>>stud[i].m1>>stud[i].m2>>stud[i].m3;
 }
 for(i=1;i<=1;i++)
 {
  cout<<"\n REG_NO  : "<<<"\n NAME    : "<<<"\n M1      : "<<<"\n M2      : "<<<"\n M3      : "<
  stud[i].total = stud[i].m1+stud[i].m2+stud[i].m3;
  stud[i].avg = stud[i].total/3;
  cout<<"\n TOTAL   : "<<<"\n AVERAGE : "<
  if((stud[i].m1<50 || stud[i].m2<50 || stud[i].m3<50))
  {
   cout<<"\n RESULT  : FAIL"<
  }
  else
  {
   cout<<"\n RESULT  : PASS"<
  }
  if(stud[i].avg>90)
  {
   cout<<"\n GRADE   : OUTSTANDING";
  }
  else if(stud[i].avg>75 && stud[i].avg <90)
  {
   cout<<"\n GRADE   : FIRST CLASS";
  }
  else if(stud[i].avg>60 && stud[i].avg<75)
  {
   cout<<"\n GRADE   : SECOND CLASS";
  }
  else if(stud[i].avg>50 && stud[i].avg<60)
  {
   cout<<"\n GRADE   : THIRD CLASS";
  }
  else
  {
   cout<<"\n GRADE   : NIL";
  }
 }
 getch();
 return 0;
}

No comments:

Post a Comment