/* DemoOperators2.cpp CIS 150 5/26/2005 David Klick This program demonstrates type casting. */ #include using std::cout; using std::endl; using std::cin; int main(void) { int num1, num2; int sum, difference, product, remainder; double quotient; cout << "Enter two non-zero integers: "; cin >> num1 >> num2; sum = num1 + num2; difference = num1 - num2; product = num1 * num2; // result is double since we cast one of the ints to a double quotient = (double)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 5%2 is 1 */