(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 // allows program to perform input and output
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
```

Computer Science & Information Technology

You might also like to view...

Match the following Trust Center options with the correct description:

I. Add-Ins II. Privacy Options III. Trusted Documents IV. Trusted Publishers V. File Block Settings A. Enables you to trust network documents to open without Excel displaying any security warnings B. Directs Excel to trust digitally signed workbooks by certain creators C. Enables you to select which types of files, such as macros, to open in Protected View or which file type to prevent saving a file in D. Enables you to deal with nonmacro privacy issues E. Enables you to specify which add-ins will be allowed to run given the desired level of security

Computer Science & Information Technology

On a Web page, a(n) ________ effect is one that changes on the page

Fill in the blank(s) with correct word

Computer Science & Information Technology

________ can be used to make column widths match the size of the data values in the cell

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Summarize the Recommendations issued by the Financial Action Task Force

What will be an ideal response?

Computer Science & Information Technology