10
Calc
- #include <iostream>
- #include <cstdlib>
- int main() {
- using std::cin;
- using std::cout;
- using std::endl;
- int x, y, r;
- char op;
- cout << "Enter two integers: ";
- cin >> x >> y;
- cout << "Enter an operator (+, -, *, /, %): ";
- cin >> op;
- switch ( op ) {
- case '+':
- r = x + y;
- break;
- case '-':
- r = x - y;
- break;
- case '*':
- r = x * y;
- break;
- case '/':
- r = x / y;
- break;
- case '%':
- r = x % y;
- break;
- }
- cout << endl << x << op << y << "=" << r << endl;
- exit( 0 );
- }
Comments