/* DemoOperators.cpp CIS 150 5/26/2005 David Klick This program demonstrates some basic C++ operators. */ #include using std::cout; using std::endl; using std::cin; int main(void) { int num1, num2; int sum, difference, product, quotient, remainder; cout << "Enter two non-zero integers: "; cin >> num1 >> num2; sum = num1 + num2; difference = num1 - num2; product = num1 * num2; // result of integer division will be an integer quotient = num1 / num2; remainder = num1 % num2; cout << num1 << '+' << num2 << " is " << sum << '\n'; cout << num1 << '-' << num2 << " is " << difference << '\n'; cout << num1 << '*' << num2 << " is " << product << '\n'; cout << num1 << '/' << num2 << " is " << quotient << '\n'; cout << num1 << '%' << num2 << " is " << remainder << '\n'; return 0; } /* Sample output: Enter two non-zero integers: 5 2 5+2 is 7 5-2 is 3 5*2 is 10 5/2 is 2 5%2 is 1 */