(Find the Largest) The process of finding the largest number (i.e., the maximum of a group of numbers) is used frequently in computer applications. For example, a program that determines the winner of a sales contest inputs the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write a C++ program that uses a while statement to de- termine and print the largest number of 10 numbers input by the user. Your program should use three variables, as follows:

counter: A counter to count to 10 (i.e., to keep track of how many numbers have
been input and to determine when all 10 numbers have been processed).

number: The current number input to the program.
largest: The largest number found so far.


```
// Finding the largest number.
#include
#include // parameterized stream manipulators
using namespace std;

int main()
{ int counter = 0; // counter for 10 repetitions
int number; // current number input
int largest; // largest number found so far

cout << "Enter the first number: "; // prompt for first number
cin >> largest; // get first number

while ( ++counter < 10 ) // loop 10 times
{
cout << "Enter the next number : "; // prompt for next input
cin >> number; // get next number

// if current number input is greater than largest number,
// update largest
if ( number > largest )
largest = number;
} // end while
cout << "Largest is " << largest << endl; // display largest number
} // end main
```

Computer Science & Information Technology

You might also like to view...

FIGURE 8-1Referring to Figure 8-1 above, the following field is NOT left-aligned using a non-breaking space ____.

A. Name B. State C. Phone D. City

Computer Science & Information Technology

HTML is commonly carried over which protocol?

What will be an ideal response?

Computer Science & Information Technology

Identify the first step that is executed when JavaScript encounters code that references an object property or method.

A. Check for the property or method with the object's prototype B. Continue moving down the chain until the property or method is located or the end of the chain is reached C. If the prototype is an instance of another object, check for the property or method in that object D. Check for the property or method within the current object instance

Computer Science & Information Technology

Match each of the following terms to its description:I.II.>III.=A.Greater than or equal toB.Not equalC.Greater thanD.Less than or equal toE.Less than

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

Computer Science & Information Technology