Advertisement
pranto_95

dx

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