to calc marks
#include<iostream>
using namespace std;
class student
{
public:
char name[30];
int roll;
int marks[5];
float result;
void getdata();
float displayResult();
};
void student::getdata ()
{
cout<<"\nenter name\t";
cin>>name;
cout<<"\nenter rollno\t";
cin>>roll;
cout<<"\nenter marks\t";
for(int i=0;i<5;i++)
{
cin>>marks[i];
cout<<"\t";
}
}
float student::displayResult()
{ int sum=0;
for(int i=0;i<4;i++)
{
sum=sum+marks[i];
}
result=sum/5;
return result;
}
int main ()
{
student s[34];
for(int j=1;j<=34;j++)
{
cout<<"\nEnter detail of student "<<j<<"\n";
s[j].getdata();
float r=s[j].displayResult();
cout<<"\nResult of student\t"<<j<<"\tis\t"<<r<<"\n";
}
return 0;
}
using namespace std;
class student
{
public:
char name[30];
int roll;
int marks[5];
float result;
void getdata();
float displayResult();
};
void student::getdata ()
{
cout<<"\nenter name\t";
cin>>name;
cout<<"\nenter rollno\t";
cin>>roll;
cout<<"\nenter marks\t";
for(int i=0;i<5;i++)
{
cin>>marks[i];
cout<<"\t";
}
}
float student::displayResult()
{ int sum=0;
for(int i=0;i<4;i++)
{
sum=sum+marks[i];
}
result=sum/5;
return result;
}
int main ()
{
student s[34];
for(int j=1;j<=34;j++)
{
cout<<"\nEnter detail of student "<<j<<"\n";
s[j].getdata();
float r=s[j].displayResult();
cout<<"\nResult of student\t"<<j<<"\tis\t"<<r<<"\n";
}
return 0;
}
Comments
Post a Comment