-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
61 lines (56 loc) · 1020 Bytes
/
main.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
#include <iostream>
using namespace std;
void dOptions()
{
cout<<"Please select an arithmetic operation by inputting a number \n";
cout<<"1.Addition\n";
cout<<"2.Subtraction\n";
cout<<"3.Multiplication\n";
cout<<"4.Division\n";
cout<<"5.Exit\n";
}
float addNum(float a,float b)
{
return a+b;
}
float subNum(float a,float b)
{
return a-b;
}
float multNum(float a,float b)
{
return a*b;
}
float divNum(float a,float b)
{
return a/b;
}
int main()
{
int x,y,z;
dOptions();
cin>>x;
cout<<"Input the two operands\n";
cin>>y>>z;
do
{
switch(x)
{
case 1:
cout<<addNum(y,z);
break;
case 2:
cout<<subNum(y,z);
break;
case 3:
cout<<multNum(y,z);
break;
case 4:
cout<<divNum(y,z);
break;
default:
cout<<"Choose an operator";
}
}
while(x>5);
}