-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment04.cpp
101 lines (97 loc) · 1.76 KB
/
Assignment04.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
ASSIGNMENT_NO_04
Name: Shete Siddarth Sudhir
ROllno:61 Div:C
Problem Statement:
Write a c++ program to create base person,
Derive acedamic performance class degree and percentage from person
class and display biodata of person.
*/
#include<iostream> //Header file
using namespace std;
class person{ //class declaration
protected: //Acess specifier
char name[50]; //data members
long int pno;
public: //Acess specifier
void getdata() //member function
{
cout<<"Enter name of student"<<endl; //input and
output statements
cin>>name;
cout<<"Enter the phone number"<<endl;
cin>>pno;
}
};
class academic_performance : public person //Derived class
person
{
char deg[20]; //data members
int per;
public: //Acess
specifier
void setdata()
//member function
{
cout<<"Enter the name of qualified degree "<<endl;
cin>>deg;
cout<<"Enter the percentage "<<endl;
cin>>per;
}
void display(){
cout<<name<<"\t"<<pno<<"\t"<<deg<<"\t"<<per<<endl;
}
};
int main() //main function
{
int i,a;
cout<<"Enter the number of persons"<<endl;
cin>>a;
academic_performance p[a];
for(i=0;i<a;i++)
{
p[i].getdata();
p[i].setdata();
}
cout<<"\n name \t phone number \t degree \t
percentage \n";
for(i=0;i<a;i++)
{
p[i].display();
}
return 0; //return
value/type
}
/*
Output:
Enter the number of persons
3
Enter name of student
Siddarth
Enter the phone number
123456
Enter the name of qualified degree
btech
Enter the percentage
86
Enter name of student
rajesh
Enter the phone number
7894556
Enter the name of qualified degree
be
Enter the percentage
88
Enter name of student
krushna
Enter the phone number
852147
Enter the name of qualified degree
bsc
Enter the percentage
78
name phone number degree percentage
Siddarth 123456 btech 86
rajesh 7894556 be 88
krushna 852147 bsc 78
*/