-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr5.cpp
More file actions
77 lines (48 loc) · 1010 Bytes
/
pr5.cpp
File metadata and controls
77 lines (48 loc) · 1010 Bytes
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
using namespace std;
class student{
protected:
string name;
int roll_no;
public:
void get_data(void);
void display_data(void);
};
class marks : public student{
protected:
int sub1,sub2,sub3,sub4,sub5;
public :
void get_marks();
};
class result : public marks{
float per;
public :
void cal_per();
void display_per();
};
void student :: get_data(){
cout<<"\n Enter Name and roll no. of student\n";
cin>>name >>roll_no;
}
void student :: display_data(){
cout<<"\n Name\t\t:"<<name;
cout<<"\n Roll no.\t:"<<roll_no;
}
void marks :: get_marks(){
cout<<"\n Enter the marks of 5 subjects\n";
cin>>sub1 >>sub2 >>sub3 >>sub4 >>sub5;
}
void result :: cal_per(){
per = (sub1+sub2+sub3+sub4+sub5)/5.0f;
}
void result :: display_per(){
cout<<"\n Percentage\t:"<<per<<"%";
}
int main(){
result s1;
s1.get_data();
s1.get_marks();
s1.cal_per();
s1.display_data();
s1.display_per();
}