(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...

How many users can actively connect to a Windows Server Essentials Experience role configuration?

A) 10 B) 15 C) 20 D) 25

Computer Science & Information Technology

Information systems designed for a specific industry or enterprise may use vertical market software.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology