#include <iostream>
int main() {
double num1, num2;
char operation;
std::cout << "Enter a number: ";
std::cin >> num1;
std::cout << "Enter another number: ";
std::cin >> num2;
std::cout << "Enter an operation (+, -, *, /): ";
std::cin >> operation;
if (operation == '+') {
std::cout << num1 + num2 << std::endl;
} else if (operation == '-') {
std::cout << num1 - num2 << std::endl;
} else if (operation == '*') {
std::cout << num1 * num2 << std::endl;
} else if (operation == '/') {
std::cout << num1 / num2 << std::endl;
} else {
std::cout << "Invalid operator" << std::endl;
}
return 0;
}
This program prompts the user to enter two numbers and an operation, and then
performs the specified operation on the numbers. The ‘if’ statement is used to determine
which operation to perform based on the value of the operation variable.