-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodsoft_Task2.cpp
More file actions
49 lines (43 loc) · 1.29 KB
/
Copy pathCodsoft_Task2.cpp
File metadata and controls
49 lines (43 loc) · 1.29 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
#include <iostream>
#include <cmath> n
#include <string>
using namespace std;
void calc_ulator() {
int num1, num2;
cout << "Enter 'A' as your 1st no. \n";
cin >> num1;
cout << "Enter 'B' as your 2nd no. \n";
cin >> num2;
cout << "So, What do you want? + , - , * , / , ** . \n Other options will be coming soon." << endl;
string operation;
cin >> operation;
if (operation == "+") {
cout << (num1 + num2) << endl;
} else if (operation == "-") {
cout << (num1 - num2) << endl;
} else if (operation == "*") {
cout << (num1 * num2) << endl;
} else if (operation == "/") {
if (num2 != 0) {
cout << (static_cast<double>(num1) / num2) << endl;
} else {
cout << "Error! Division by zero." << endl;
}
} else if (operation == "") {
cout << pow(num1, num2) << endl;
} else {
cout << "Error! Please check your input. \n Other options will be available soon." << endl;
}
cout << "Calculate again? (y/n): ";
char again;
cin >> again;
if (tolower(again) == 'y') {
calc_ulator();
} else {
cout << "Please be back for more calculations..." << endl;
}
}
int main() {
calc_ulator();
return 0;
}