-
Notifications
You must be signed in to change notification settings - Fork 0
/
inherit 1.cpp
53 lines (53 loc) · 1.07 KB
/
inherit 1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<iostream>
using namespace std;
class student{
protected:
int roll;
string name;
public:
void ip(){
cout<<"Enter The Name Of Student";
cin>>name;
cout<<"Enter The Roll No. Of Student";
cin>>roll;
}
void show(){
cout<<"The name of student is :"<<name;
cout<<"The Roll No. Of Student is :"<<roll;
}
};
class exam:public student{
private:
int m,s,e;
float percentage,total;
public:
void get(){
cout<<"Enter The Marks of maths";
cin>>m;
cout<<"Enter The Marks of science";
cin>>s;
cout<<"Enter The Marks Of english";
cin>>e;
}
void calc(){
total=m+s+e;
percentage=total/3;
}
void op(){
cout<<"The name of student is :"<<name;
cout<<"The Roll No. Of Student is :"<<roll;
cout<<"The Marks of maths is :"<<m;
cout<<"The Marks of science is :"<<s;
cout<<"The Marks of english is :"<<e;
cout<<"The total marks is :"<<total;
cout<<"The percentage is :"<<percentage;
}
};
int main(){
exam e1;
e1.ip();
e1.get();
e1.calc();
e1.op();
return 0;
}