-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirfn.cpp
More file actions
111 lines (111 loc) · 1.52 KB
/
virfn.cpp
File metadata and controls
111 lines (111 loc) · 1.52 KB
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
102
103
104
105
106
107
108
109
110
111
#include "iostream"
using namespace std;
class stu
{
char name[20];
float sgpa;
int out;
public:
virtual void getname()
{
cout<<"Enter Student's name: ";
cin>>name;
}
virtual void getdata()
{
cout<<"Enter SGPA: ";
cin>>sgpa;
}
virtual void isoutstanding()
{
if(sgpa>8.5)
out=1;
else
out=0;
}
virtual int retout()
{
return out;
}
virtual void show()
{
cout<<"Name:"<<name<<"\tSGPA:"<<sgpa<<endl;
}
};
class prof: public stu
{
char name[25];
int noop;
int out;
public:
void getname()
{
cout<<"Enter Professor's name: ";
cin>>name;
}
void getdata()
{
cout<<"Enter no of Publications: ";
cin>>noop;
}
void isoutstanding()
{
if(noop>100)
out=1;
else
out=0;
}
int retout()
{ return out;}
void show()
{
cout<<"Name:"<<name<<"\tPublications:"<<noop<<endl;
}
};
int main()
{
stu s[10];
prof p[10];
stu *sptr;
char c;
int en,i;
cout<<"Professor or Student: ";
cin>>c;
if(c=='S' or c=='s')
{
cout<<"Enter number of entries: ";
cin>>en;
for(i=0;i<en;i++)
{
sptr=&s[i];
sptr->getname();
sptr->getdata();
sptr->isoutstanding();
}
for(i=0;i<en;i++)
{
sptr=&s[i];
if(sptr->retout()==1)
sptr->show();
}
}
else if (c=='P' or c=='p')
{
cout<<"Enter number of entries: ";
cin>>en;
for(i=0;i<en;i++)
{
sptr=&p[i];
sptr->getname();
sptr->getdata();
sptr->isoutstanding();
}
for(i=0;i<en;i++)
{
sptr=&s[i];
if(sptr->retout()==1)
sptr->show();
}
}
return 0;
}