-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatic_Member_Function 1.CPP
92 lines (79 loc) · 1.28 KB
/
Static_Member_Function 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
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
#include<iostream.h>
#include<conio.h>
class student
{
private:
static float rollno;
static int count;
float mark1,mark2,percent;
public:
void get()
{
cout<<"Enter marks for Subject 1: ";
cin>>mark1;
cout<<"Enter marks for Subject 2: ";
cin>>mark2;
}
void calcpercent()
{
percent=mark1+mark2/2.0;
}
void grade()
{
if(percent>=95)
{
cout<<"Grade A"<<endl;
}
else if(percent>=80)
{
cout<<"Grade B"<<endl;
}
else if(percent>=60)
{
cout<<"Grade C"<<endl;
}
else if(percent>=40)
{
cout<<"Grade D"<<endl;
}
else
{
cout<<"Grade E"<<endl;
}
}
static void showcount()
{
count++;
cout<<"\nCount: "<<count<<endl;
}
static void showrollno()
{
rollno++;
cout<<"\nRoll No. : "<<rollno<<endl;
}
void display()
{
cout<<"Marks of Subject 1: "<<mark1<<endl;
cout<<"Marks of Subject 2: "<<mark2<<endl;
cout<<"Percentage : "<<percent<<endl;
}
};
float student::rollno=1981033;
int student::count;
void main()
{
clrscr();
student s1,s2;
student::showrollno();
s1.get();
s1.calcpercent();
s1.display();
s1.grade();
student::showcount();
student::showrollno();
s2.get();
s2.calcpercent();
s2.display();
s2.grade();
getch();
}