forked from Backslash-Computing-Society/Hacktober
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprac.cpp
More file actions
66 lines (64 loc) · 1.09 KB
/
prac.cpp
File metadata and controls
66 lines (64 loc) · 1.09 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
#include<iostream>
using namespace std;
class calc{
int a,b,sum,diff,prod,quot;
public:
void set(int x,int y)
{
a=x;
b=y;
}
int add()
{
sum=a+b;
return sum;
}
int sub()
{
diff=a-b;
return diff;
}
int mult()
{
prod=a*b;
return prod;
}
int div()
{
quot=a/b;
return quot;
}
};
int main()
{
calc vals;
int n1,n2,c;
cout<<"Enter first number:";
cin>>n1;
// cout<<"past n1";
cout<<"Enter second number:";
cin>>n2;
// cout<<"past n2";
vals.set(n1,n2);
// cout<<"Past vals set";
cout<<"Welcome to Calculator!"<<endl<<"Enter your choice:-"<<endl<<"1. Add two numbers"<<endl<<"2. Subtract two numbers"<<endl<<"3. Multiply two numbers"<<endl<<"4. Divide two numbers"<<endl;
cin>>c;
switch(c)
{
case 1:
cout<<"Sum of the numbers is:"<<vals.add()<<endl;
break;
case 2:
cout<<"Difference of the numbers is:"<<vals.sub()<<endl;
break;
case 3:
cout<<"Product of the numbers is:"<<vals.mult()<<endl;
break;
case 4:
cout<<"Division of the numbers is:"<<vals.div()<<endl;
break;
default:
cout<<"Works";
}
return 0;
}