-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPgNUgStudentInheritance.C
76 lines (72 loc) · 1.5 KB
/
PgNUgStudentInheritance.C
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
#include <bits/stdc++.h>
using namespace std;
class STUDENT
{
protected:
int USN, age;
char name[10];
};
class PGSTUDENT : protected STUDENT
{
int semester, fees, stipend;
public:
PGSTUDENT()
{
cout << "\nenter PG student USN\t";
cin >> USN;
cout << "\nenter PG student name\t";
cin >> name;
cout << "\nenter PG student Age\t";
cin >> age;
cout << "\nenter semester\t";
cin >> semester;
cout << "\nenter fees\t";
cin >> fees;
cout << "\nenter stipend\t";
cin >> stipend;
}
int Age()
{
return age;
}
};
class UGSTUDENT : protected STUDENT
{
int semester, fees, stipend;
public:
UGSTUDENT()
{
cout << "\nenter UG student USN\t";
cin >> USN;
cout << "\nenter UG student name\t";
cin >> name;
cout << "\nenter UG student Age\t";
cin >> age;
cout << "\nenter semester\t";
cin >> semester;
cout << "\nenter fees\t";
cin >> fees;
cout << "\nenter stipend\t";
cin >> stipend;
}
int Age()
{
return age;
}
};
int main()
{
int N;
float avg1 = 0, avg2 = 0;
cin >> N;
PGSTUDENT ob1[N];
UGSTUDENT ob2[N];
for (int i = 0; i < N; i++)
{
avg1 += ob1[i].Age();
avg2 += ob2[i].Age();
}
cout << avg1 / N << endl;
cout << avg2 / N << endl;
return 0;
}