Resources » Articles/Knowledge Sharing » Computer & Technology

C++ Program for Multiple Inheritance


Posted Date: 14-Jun-2008  Last Updated:   Category: Computer & Technology    
Author: Member Level: Gold    Points: 2



/* ASSIGNMENT NO.5 */
/* MULTILEVEL INHERITANCE */
/* STORE STUDENTS DATA */


#include
#include
#include
#include

class student
{
protected:
char name[31];
int rollno;
public:
void input() //get name & roll no. of student
{
cout<<"\n\n Enter name:";
cin>>name;
cout<<"\n Enter roll no:";
cin>>rollno;
}
void show() //show name & roll no
{
cout<<"\n\n Name: "< }
}; //end of class student

class average:public student
{
protected:
int s1;
int s2;
int s3;
int s4;
int s5;
float average;
public:
void avg() //get marks in 5 subjects
{
cout<<"\n\n Enter the marks in 5 subjects(out of 100): ";
cin>>s1>>s2>>s3>>s4>>s5;
average=float(s1+s2+s3+s4+s5)/5;
cout<<"\n\n Average is:"< }
}; //end of class average

class percent:public average
{
protected:
float percentage;
public:
void perct()
{
float total=s1+s2+s3+s4+s5;
percentage=float((total*100)/500);
cout<<"\n\n The percentage is:"< if(percentage>=65)
{
cout<<"\nGrade is: FIRST CLASS";
}
else if(percentage>=50 && percentage<65)
{
cout<<"\nGrade is: SECOND CLASS";
}
else if(percentage>=40 && percentage<50)
{
cout<<"\nGrade is: THIRD CLASS";
}
else
{
cout<<"\n STUDENT IS FAIL";
}
}
}; //end of class percent

void main()
{
clrscr();
int no;
cout<<"\n Enter no. of students: ";
cin>>no;
for(int i=0;i {
percent s2;
s2.input();
s2.show();
s2.avg();
s2.perct();
}
getch();
} //end of main


Did you like this resource? Share it with your friends and show your love!




Responses to "C++ Program for Multiple Inheritance"
Guest Author: Billy L     29 May 2013
C++ Program for Multiple Inheritance and its code method attracted me a lot, C++ code is very helpful - heading amazed me up, like this code anyhow. Good job done


Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    Online Members

    Danish Khan
    More...
    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.