-
Notifications
You must be signed in to change notification settings - Fork 0
/
task2.c++
39 lines (33 loc) · 1.09 KB
/
task2.c++
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
#include <iostream>
int main() {
double num1, num2;
char operation;
std::cout << "Enter the first number: ";
std::cin >> num1;
std::cout << "Enter the second number: ";
std::cin >> num2;
std::cout << "Choose an operation (+, -, *, /): ";
std::cin >> operation;
switch (operation) {
case '+':
std::cout << num1 << " + " << num2 << " = " << num1 + num2 << "\n";
break;
case '-':
std::cout << num1 << " - " << num2 << " = " << num1 - num2 << "\n";
break;
case '*':
std::cout << num1 << " * " << num2 << " = " << num1 * num2 << "\n";
break;
case '/':
if (num2 != 0) {
std::cout << num1 << " / " << num2 << " = " << num1 / num2 << "\n";
} else {
std::cout << "Error: Division by zero is not allowed.\n";
}
break;
default:
std::cout << "Invalid operation. Please choose from +, -, *, or /.\n";
break;
}
return 0;
}