-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCalculator_Function.cpp
69 lines (64 loc) · 1.36 KB
/
Calculator_Function.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
#include <iostream>
using namespace std;
int add(int x, int y){
return x+y;
}
int subtract(int x, int y){
return x-y;
}
int multiply(int x, int y){
return x*y;
}
int divide(int x, int y){
return x/y;
}
void display(){
}
int main(){
int u,x,y,z;
while(1){
cout<<endl<<" 1 for addition"<<endl;
cout<<" 2 for addition"<<endl;
cout<<" 3 for addition"<<endl;
cout<<" 4 for addition"<<endl;
cout<<"Enter option : ";
cin>>u;
switch(u){
case 1:
cout<<"Enter first number : ";
cin>>x;
cout<<"Enterr second number : ";
cin>>y;
z=add(x,y);
cout<<"Addition is : "<<z;
break;
case 2:
cout<<"Enter first number : ";
cin>>x;
cout<<"Enterr second number : ";
cin>>y;
z=subtract(x,y);
cout<<"Subtraction is : "<<z;
break;
case 3:
cout<<"Enter first number : ";
cin>>x;
cout<<"Enterr second number : ";
cin>>y;
z=multiply(x,y);
cout<<"Miltiplication is : "<<z;
break;
case 4:
cout<<"Enter first number : ";
cin>>x;
cout<<"Enterr second number : ";
cin>>y;
z=divide(x,y);
cout<<"Division is : "<<z;
break;
default:
cout<<"Wrong value input please try again";
break;
}
}
}