# Result of Students coderinme

#### Result of Students coderinme

Consider the multi-level class inheritance relationship given in the
figure.
Assume that the following rules are applicable to process the result:
1. A student must obtain at least 40% marks to clear a paper.
2. If a student has cleared all the papers then he/she is declared “Pass”
otherwise “Fail”.
3. Division is awarded to students whose result is “pass”:
First : if per>=60%
Second : if per>=45% and per=40% and< 45%
Write a complete program in C++ to implement this class inheritance
relationship and process the result of five students.
Solution:

``````#include<iostream.h>
#include<conio.h>
class student
{
protected:
int rollno;
char name;
char course;
public:
void input()
{
cout<<"Enter RollNo.,Name and Course: ";
cin>>rollno>>name>>course;
}
void disp()
{
cout<<"RollNo: "<<rollno<<"\t\tName: "<<name<<"\t\tCourse: "<<course<<endl;
}
};
class marks:public student
{
protected:
char paper1;
int obtd1;
int max1;
char paper2;
int obtd2;
int max2;
char paper3;
int obtd3;
int max3;
void input_()
{
cout<<endl<<"Enter the name of paper1,Obtained marks in paper1 and Max marks in
paper1"<<endl;
fflush(stdin);
cin.getline(paper1,20);
cin>>obtd1>>max1;
cout<<endl<<"Enter the name of paper2,Obtained marks in paper2 and Max marks in
paper2"<<endl;
fflush(stdin);
cin.getline(paper2,20);
cin>>obtd2>>max2;
cout<<endl<<"Enter the name of paper3,Obtained marks in paper3 and Max marks in
paper3"<<endl;
fflush(stdin);
cin.getline(paper3,20);
cin>>obtd3>>max3;
}
void disp_()
{
cout<<"Paper#1 Name: "<<paper1<<"\tobtained marks: "<<obtd1<<"\tmax marks:
"<<max1<<endl;
cout<<"Paper#2 Name: "<<paper2<<"\t\tobtained marks: "<<obtd2<<"\tmax marks:
"<<max2<<endl;
cout<<"Paper#3 Name: "<<paper3<<"\tobtained marks: "<<obtd3<<"\tmax marks:
"<<max3<<endl;
}
};
class result:public marks
{
int totobtd,totmax;
float per;
char result;
char division;
public:
void processresult(){
input();
input_();
totobtd=obtd1+obtd2+obtd3;
totmax=max1+max2+max3;
per=(totobtd*100)/totmax;
if(per<40)
{
strcpy(result,"FAIL");
strcpy(division,"");
}
else
{
if(per>=60)
{
strcpy(result,"PASS");
strcpy(division,"FIRST");
}
else if(per>=45&&per<60)
{
strcpy(result,"PASS");
strcpy(division,"SECOND");
}
else if(per>=40&&per<45)
{
strcpy(result,"PASS");
strcpy(division,"THIRD");
}
}
}
void display()
{
disp();
disp_();
cout<<"Result: "<<result<<"\t\tDivision: "<<division<<"\n";
}
};
int main()
{
result s;
int i;
for(i=0;i<5;i++){
s[i].processresult();
cout<<"\n";
}
cout<<"\n";
for(i=0;i<5;i++)
{
s[i].display();
cout<<"\n";
}
getch();
return 0;
}`````` 