#include<iostream.h>
#include<conio.h>
class student
{
protected:
int rollno;
char name[50];
public:
student()
{
cout<<"Enter the Rollno : ";
cin>>rollno;
cout<<"Enter the Name : ";
cin>>name;
}
void stud_show()
{
cout<<"\tStudent Record\n Rollno : "<<rollno<<"\n Name : "<<name;
}
};
class test : virtual public student
{
protected:
float sub[5];
public:
test();
void test_show();
};
test::test()
{
cout<<"\tEnter Marks\n";
for(int i=0;i<5;i++)
{
cout<<"Subject "<<i<<": ";
cin>>sub[i];
}
}
void test::test_show()
{
cout<<"\nMarks";
for(int i=0;i<5;i++)
cout<<"\nSubject "<<i<<": "<<sub[i];
}
class sports : virtual public student
{
protected:
float score;
public :
sports()
{
cout<<"Enter Sports Score :";
cin>>score;
}
void sports_show()
{
cout<<"\n Sports score :"<<score;
}
};
class result : public test,public sports
{
float total;
public:
void result_show();
};
void result::result_show()
{
total=0;
for(int i=0; i<5;i++)
total+=sub[i];
cout<<"\n Total : "<<total+score;
}
int main()
{
clrscr();
result sud;
sud.stud_show();
sud.test_show();
sud.sports_show();
sud.result_show();
getch();
return 0;
}
0 comments:
Post a Comment