-
Notifications
You must be signed in to change notification settings - Fork 48
/
calculator.cpp
57 lines (55 loc) · 1.08 KB
/
calculator.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
#include<iostream>
using namespace std;
void add(int a, int b)
{
cout<< a+b;
}
void sub(int a , int b)
{
cout<< a-b;
}
void mul(int a, int b)
{
cout<<a*b;
}
void divide(int a ,int b)
{
cout<< a/b;
}
void modulo(int a ,int b)
{
cout<<a%b;
}
main()
{
int op,a,b;
int i;
cout<<"2 NUMBER CALCULATOR";
cout<<"---option 1---ADD"<<endl;
cout<<"---option 2---SUB"<<endl;
cout<<"---option 3---MUL"<<endl;
cout<<"---option 4---DIVIDE"<<endl;
cout<<"---option 5---MODULO"<<endl;
cout<<"enter first number";
cin>>a;
cout<<"enter second number";
cin>>b;
cout<<"ENTER YOUR OPTION"<<endl;
cin>>op;
switch (op)
{
case 1:add(a,b)/* constant-expression */;
/* code */
break;
case 2:sub(a,b);
break;
case 3:mul(a,b);
break;
case 4: divide(a,b);
break;
case 5:modulo(a,b);
break;
default: cout<<"enter valid option";
break;
}
}