#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
{
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 result : public student,public test
{
float total;
public:
void result_show();
};
void result::result_show()
{
for(int i=0; i<5;i++)
total+=sub[i];
cout<<"\n Total : "<<total;
}
int main()
{
clrscr();
result sud;
sud.stud_show();
sud.test_show();
sud.result_show();
getch();
return 0;
}
0 comments:
Post a Comment