#include<iostream>
#include<string>
using namespace std;
class student
{
private:
string fname;
string name;
int s1,s2,s3;
int avg,sum;
public:
void getData()
{
cout<<"Enter name of student:";getline(cin,name);
cout<<"Enter marks of subject 1:";cin>>s1;
cout<<"Enter marks of subject 2:";cin>>s2;
cout<<"Enter marks of subject 3:";cin>>s3;
sum=s1+s2+s3;
avg=sum/3;
}
void showData()
{
cout<<"*********Result of students************"<<endl;
cout<<"Name of student :"<<name<<endl;
cout<<"Subject 1 Marks :"<<s1<<endl;
cout<<"Subject 2 Marks :"<<s2<<endl;
cout<<"Subject 3 Marks :"<<s3<<endl;
cout<<"Total Obtained Marks :"<<sum<<endl;
cout<<"Averages Marks of student :"<<avg<<endl;
}
};
int main()
{
student std1;
std1.getData();
std1.showData();
return 0;
}
No comments:
Post a Comment