Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  f
Language: C/C++
Code:
#include <stdio.h>
class STUDENT
{float percentage;
char grade;
public:
int rollno;
char name[40];
float marks[3];
void initialize();
float percentagemarks();
char grade();
};
void STUDENT::intialize()
{cout<<"Enter name of student";
cin.getline(name,20)
for(int i=0;i<3;i++)
{cout<<"Enter marks for the subject";
cin>>marks[i];
}

float STUDENT::percentagemarks()
{percentage=(marks[1]+marks[2]+marks[3])/3);
}
char STUDENT::grade()
{if(percentage<50)
 grade='F';
else
if((percentage>=50)&&(percentage<60))
grade='D';
else if((percentage>=60)&&(percentage<75)
grade='C';
else
if((percentage>=75)&&(percentage<90))
grade='B';
else if((percentage>=90)&&(percentage<100))
grade='C';
}
main()
{STUDENT a[20];
for(int i=0;i<20;i++)
{STUDENT a[i].initialize();
STUDENT a[i].percentage();
STUDENT a[i].grade();
}
Comments: