Question 1.23:

write a program that asks the user to enter two numbers, obtains the two nmubers from the user and prints the sum, product, difference, and quotient of the two numbers.

ps: wordpress has trouble rendering double quotes so some double quotes may look different from normal double quotes. to make the program work just change all the double quotes to normal double quotes. ta.

// ex1-23.cpp : main project file.
// question 1.23:
// write a program that asks the user to enter two numbers, obtains the numbers from
// the user and prints the sum, product, difference, and quotient of the two numbers.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int num1 = 0, // first input integer
num2 = 0, // second input integer
sum = 0, // sum of the two integers
product = 0, // product of two integers
difference = 0; // difference of two integers
double quotient = 0.00; // quotient of two integers
cout << num1 << num2;
// sum two input integers
sum = num1 + num2;
// product of two input integer
product = num1 * num2;
// difference of two input integer
difference = num1 - num2;
// quotient of two input integer
quotient = double(num1)/double(num2);
cout << "sum: " << num1 << endl;
cout << "product: " << product << endl;
cout << "difference: " << difference << endl;
cout << "quotient: " << quotient << endl;
return 0;
}

### Like this:

Like Loading...

*Related*