PROGRAM WITH CLASS TO STORE AND FIND AVERAGE MARKS OF A STUDENT

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class report
{
int admno;
char name[20];
float marks[5];
float avg;
float getavg()
{
float k=0.0;
k=(marks[0]+marks[1]+marks[2]+marks[3]+marks[4])/5;
return k;
}
public:
void readinfo()
{
cout<<“enter admission number of the student “;
cin>>admno;
cout<<“enter his or her name “;
gets(name);
cout<<“enter marks obtained in 5 subjects “;
cin>>marks[0]>>marks[1]>>marks[2]>>marks[3]>>marks[4];
avg=getavg();
}
void display()
{
cout<<“\nname of the student “<<name;
cout<<“\nadmission number of student is “<<admno;
cout<<“\naverage marks obtained is “<<avg;
}
};
void main()
{
clrscr();
report R1;
R1.readinfo();
R1.display();
getch();

Comments

Popular Posts