Advertisement
pranto_95

Suppose there are two classes as a student general marks and

Oct 6th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class student_general_marks
  4. {
  5. protected:
  6.     int roll;
  7.     float marks1;
  8.     float marks2;
  9.     public:
  10.     void General(){
  11.     cout<<"Enter roll number"<<endl;
  12.     cin>>roll;
  13.     cout<<"Enter marks1"<<endl;
  14.     cin>>marks1;
  15.     cout<<"Enter marks2"<<endl;
  16.     cin>>marks2;
  17.         }
  18.     };
  19.                                     class CPP_marks{
  20.                                     protected:
  21.                                     float CPP_marks;
  22.                                     public:
  23.                                     void programming(){
  24.                                     cout<<"Enter marks"<<endl;
  25.                                     cin>>CPP_marks;
  26.                                     }
  27.                                     };
  28.                                                                 class result:public student_general_marks,public CPP_marks
  29.                                                                 {
  30.                                                                 protected:
  31.                                                                 float avg;
  32.                                                                 public:
  33.                                                                 void resultdisplay(){
  34.                                                                 avg=(marks1+marks2+CPP_marks)/3.00;
  35.                                                                 cout<<"Avg is :"<<avg;
  36.                                                                 }
  37.                                                                 };
  38.  
  39.  
  40.  
  41.     int main(){
  42.         result R;
  43.         R.General();
  44.         R.programming();
  45.         R.resultdisplay();
  46.         return 0;
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement