#include <iostream>
using namespace std;
class student
{
public:
int m1,m2,m3,rollno;
char name[30];
void getdata ()
{
cout <<"Enter the roll no:";
cin >>rollno;
cout <<rollno<<endl;
cout <<"Enter the name :";
cin>>name;
cout <<name <<endl;
cout <<"Enter the three marks :";
cin >>m1>>m2>>m3;
cout <<m1<<" "<<m2<<" "<<m3<<endl;
}
};
class mark :public student
{
public:
int total;
float avg;
void calculation ()
{
total =m1+m2+m3;
avg=total/3;
}
void display ()
{
cout <<"Total= "<<total<<endl;
cout <<"Average = "<<avg<<endl;
}
};
int main() {
mark m;
m. getdata ();
m. calculation ();
m. display ();
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: