-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-calculator-v2.cpp
More file actions
33 lines (27 loc) · 787 Bytes
/
10-calculator-v2.cpp
File metadata and controls
33 lines (27 loc) · 787 Bytes
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
#include <iostream>
using namespace std;
int main() {
double num1, num2;
char oper;
cout << "Enter the first number: ";
cin >> num1;
cout << "Enter the second number: ";
cin >> num2;
cout << "Enter the operator: ";
cin >> oper;
double result;
if (oper == '+')
result = num1 + num2;
else if (oper == '-')
result = num1 - num2;
else if (oper == '*')
result = num1 * num2;
else if (oper == '/')
result = num1 / num2;
else {
cout << "Invalid Operator.";
return 1; // Si el programa o la aplicación finaliza su ejecución con código distinto a 0, se interpreta que finalizó incorrectamente.
}
cout << num1 << " " << oper << " " << num2 << " = " << result;
return 0;
}