-
Notifications
You must be signed in to change notification settings - Fork 16
/
simple-calculator.cpp
61 lines (45 loc) · 1.18 KB
/
simple-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
58
59
60
61
#include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cout << "Operator Option : \n 1) Addition \n 2) Substraction \n 3) "
"Multiplication \n 4) Division \n 5) Power \n";
cout << "What do you want to do : ";
cin >> x;
float a, b, res = 0;
if (x == 1) {
cout << "\n=== ADDITION ===\n First number : ";
cin >> a;
cout << " Second number : ";
cin >> b;
res = a + b;
} else if (x == 2) {
cout << "\n=== SUBSTRACTION ===\n First number : ";
cin >> a;
cout << " Second number : ";
cin >> b;
res = a - b;
} else if (x == 3) {
cout << "\n=== MULTIPLICATION ===\n First number : ";
cin >> a;
cout << " Second number : ";
cin >> b;
res = a * b;
} else if (x == 4) {
cout << "\n=== DIVISION ===\n First number : ";
cin >> a;
cout << " Second number : ";
cin >> b;
res = a / b;
} else if (x == 5) {
cout << "\n=== POWER ===\n First number : ";
cin >> a;
cout << " Second number : ";
cin >> b;
res = pow(a,b);
} else {
cout << "\noops currently we didn't have that option :((\n ";
}
cout << "\n=== Result : " << res << " ===\n" << endl;
return 0;
}