Search This Blog

Sunday 1 May 2016

write a c++ program to find student info using multiple inheritance

 Practical - 25


#include<iostream>
using namespace std;

class student
{
    protected:
       int no,m1,m2;
    public:
            void get()
              {
                            cout<<"Enter the Roll no :";
                            cin>>no;
                            cout<<"Enter the two marks :";
                            cin>>m1>>m2;
              }
};
class Practical
{
    protected:
       int pm;
    public:
                void getpm()
              {
                 cout<<"\nEnter the Practical mark :";
                 cin>>pm;

              }
};
class result:public student,public Practical
{
    int tot,avg;
    public:
    void display()
              {
                 tot=(m1+m2+pm);
                 avg=tot/3;
                 cout<<"\nRoll No    : "<<no<<"\nTotal      : "<<tot;
               cout<<"\nAverage    : "<<avg;
              }
};
int main()
{
   result r;
   r.get();
   r.getpm();
   r.display();
   return 0;

}

No comments:

Post a Comment