/*--------------------------------------------------------------------*/ /* Problem chapter3_101 */ /* */ /* This program will do simple +, -, *, / */ #include #include using namespace std; int main() { // Declare and initialize variables. int a=0, b=0; char c; cout << "Enter a formula for an arithmetic operation: "; cin >> a >> c >> b ; /* a loop is optional, see also ex3-101a.cpp */ while ( !cin.eof() ) { switch(c) { case '+': cout << " " << a << " + " << b << " = " << a+b << endl; break; case '-': cout << " " << a << " - " << b << " = " << a-b << endl; break; case '*': cout << " " << a << " * " << b << " = " << a*b << endl; break; case '/': cout << " " << a << " / " << b << " = " << a/b << " with remindar " << a%b << endl; break; default: cout << " I do not understand it." << endl; } cout << "Enter a formula for an arithmetic operation: "; cin >> a >> c >> b ; } // Exit program. return 0; }