#include <iostream>
using namespace std;
void sum(int a, int b) {
cout << "sum is: " << a + b;
}
void dif(int a, int b) {
cout << "different is: " << a - b;
}
void mult(int a, int b) {
cout << "multiplication is: " << a * b;
}
void division(int a, int b) {
if (b == 0) {
cout << "ERROR!";
} else {
cout << "division is: " << a / b;
}
}
int main() {
int a, b;
char op;
cout << "Enter a\n";
cin >> a;
cout << "Enter b\n";
cin >> b;
cout << "Choose operation: + = * /\n";
cin >> op;
switch (op) {
case '+':
sum(a, b);
break;
case '-':
dif(a, b);
break;
case '/':
division(a, b);
break;
case '*':
mult(a, b);
break;
default:
cout << "unknown operation!";
}
}
Comments
Leave a comment