Program to make a class student to print result of
student.
#include<iostream.h>
#include<conio.h>
class student
{
int rollno;
char name[6];
int classstud;
int marks[5];
float per;
float calculate();
public:void readmarks();
void
displaymarks();
};
float student::calculate()
{
per=0;
for(int i=0;i<=5;i++)
per+=marks[i];
per=(per/5);
return per;
}
void student::readmarks()
{
cout<<"enter rollno no.:";
cin>>rollno;
cout<<"enter the name:";
cin>>name;
cout<<"enter the class standing in:";
cin>>classstud;
cout<<"enter the marks:"<<endl;
for(int j=0;j<5;j++){
cout<<"\t enter
marks"<<j+1<<":";
cin>>marks[j];
}
}
void student::displaymarks()
{
cout<<"Rollno:"<<rollno<<endl;
cout<<"name:"<<name<<endl;
cout<<"class:"<<classstud<<endl;
cout<<"percentage:"<<calculate()<<endl;
}
int main()
{
student s1;
s1.readmarks();
s1.displaymarks();
getch();
}
OUTPUT