(Arithmetic, Smallest and Largest) Write a program that inputs three integers from the key- board and prints the sum, average, product, smallest and largest of these numbers. The screen dialog should appear as follows:
Input three different integers: 13 27 14
Sum is 54
Average is 18
Product is 4914
Smallest is 13
Largest is 27
What will be an ideal response?
```
// Exercise 2.19 Solution: ex02_19.cpp
#include
using namespace std; // program uses names from the std namespace
int main()
{
int number1; // first integer read from user
int number2; // second integer read from user
int number3; // third integer read from user
int smallest; // smallest integer read from user
int largest; // largest integer read from user
cout << "Input three different integers: "; // prompt
cin >> number1 >> number2 >> number3; // read three integers
largest = number1; // assume first integer is largest
if ( number2 > largest ) // is number2 larger?
largest = number2; // number2 is now the largest
if ( number3 > largest ) // is number3 larger?
largest = number3; // number3 is now the largest
smallest = number1; // assume first integer is smallest
if ( number2 < smallest ) // is number2 smaller?
smallest = number2; // number2 is now the smallest
if ( number3 < smallest ) // is number3 smaller?
smallest = number3; // number3 is now the smallest
cout << "Sum is " << number1 + number2 + number3
<< "\nAverage is " << ( number1 + number2 + number3 ) / 3
<< "\nProduct is " << number1 * number2 * number3
<< "\nSmallest is " << smallest
<< "\nLargest is " << largest << endl;
} // end main
```
You might also like to view...
____ simply means that the same actions taken by different people would still produce the same results.
A. Repudiation B. Reproducibility C. Integrity D. Authenticity
A occurs when an executed statement does not directly follow the previously executed statement in the written application.
a) transition b) flow c) logical error d) transfer of control