#include <iostream>
using namespace std;
class details
{
    public:
    char name[30],cls[20];
    int roll_no,mark[5],tot=0;
    float avg;
    void get1()
    {
        cout<<"\n Enter the Student Name : ";
        cin>>name;
        cout<<"\n Enter the Roll Number  : ";
        cin>>roll_no;
        cout<<"\n Enter the Class        : ";
        cin>>cls;
        cout<<"\n\n Marks......";
        for(int i=0;i<2;i++)
        {
            cout<<"\n Enter the Mark "<<i+1<<" : ";
            cin>>mark[i];
        }
    }
};
class derive1:virtual public details
{
    public:
    void get2()
    {
        for(int i=2;i<4;i++)
        {
            cout<<"\n Enter the Mark "<<i+1<<" : ";
            cin>>mark[i];
        }
    }
};
class derive2:virtual public details
{
    public:
    void get3()
    {
        cout<<"\n Enter the Mark 5 : ";
        cin>>mark[4];
    }
};
class final:public derive1,public derive2
{
    public:
    void calculate()
    {
        for(int i=0;i<5;i++)
        {
            tot=tot+mark[i];
        }
        avg=tot/5;
    }
    void display()
    {
        cout<<"\n Student Name     : "<<name;
        cout<<"\n Student Roll No. : "<<roll_no;
        cout<<"\n Student Class    : "<<cls;
        cout<<"\n\n Marks....";
        for(int i=0;i<5;i++)
        {
            cout<<"\n Mark "<<i+1<<" : "<<mark[i];
        }
        cout<<"\n\n Marks Total : "<<tot;
        cout<<"\n Marks Average : "<<avg;
    }
};
int main()
{
    final obj;
    obj.get1();
    obj.get2();
    obj.get3();
    obj.calculate();
    obj.display();
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: