Create a class named “student” that contains roll_number, stu_name and course_name,
father_name, DOB as data member and Input_student and display_student as member functions.
Create a Derived class named “exam” from the class named “student” with publicly inherited
mode. The derived class contains members as mark1,mark2,mark3 as marks of three subjects and
input_marks and display_results as member functions. Create an array of object of the “exam”
class and display the result of 10 students.
class student
{
public: int rno;
char name[20];
int m1,m2,m3;
public:
void details()
{
cout<<“\nROLL_NO NAME MARKS THREE SUBJECT \n”;
cin>>rno>>name>>m1>>m2>>m3;
}
void details(int nm)
{
cout<<“\nDetails of ONE student :\n”;
cout<<“\nROLL_NO\tNAME\tMARK1\tMARK2\tMARK3 \n”;
cout<<“=====================================\n” ;
cout<<nm<<“\t”<<name<<“\t”<<m1<<“\t”<<m2<<“\t”<<m3<<endl<<“\n\n”;
}
void details(char*)
{
cout<<rno<<“\t”<<name<<“\t”<<m1<<“\t”<<m2<<“\t”<<m3<<endl;
}
};
void main()
{
int rn,i,n;
stud s[20];
clrscr();
cout<<“How many student inform: \n”;
cin>>n;
for(i=0;i<n;i++)
{
s[i].details();
}
cout<<“Enter the roll number:\n “;
cin>>rn;
for(i=0;i<n;i++)
{
if(rn==s[i].rno)
{
s[i].details(rn);
}
}
cout<<“Details of all student: \n”;
cout<<“ROLL_NO\tNAME\tMARK1\tMARK2\tMARK3 \n\n”;
cout<<“=====================================\n” ;
for(i=0;i<n;i++)
{
s[i].details(s[i].name);
}
getch();
}
Comments
Leave a comment