-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy path3.cpp
55 lines (54 loc) · 943 Bytes
/
3.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
#include <iostream>
using namespace std;
class Counter
{
private:
int Count;
public:
Counter Init(int tempc = 0)
{
Count = tempc;
}
void count()
{
Count++;
}
int display()
{
return Count;
}
};
int main()
{
cout << "1. Intialize count" << endl;
cout << "2. Increment count" << endl;
cout << "3. Display count" << endl;
cout << "4. Exit" << endl;
Counter C1;
while(1)
{
int a;
cin >> a;
if(a == 1)
{
int c;
cout << "Enter number to initialize : ";
cin >> c;
C1.Init(c);
}
else if(a == 2)
{
C1.count();
}
else if(a == 3)
{
int res;
res = C1.display();
cout << "Count = " << res << endl;
}
else if (a==4)
{
exit(1);
}
}
}