The process of finding the largest number (i.e.,the maximum of a group of number
ID: 3614491 • Letter: T
Question
The process of finding the largest number (i.e.,the maximum of a group of numbers) is used frequently in computerapplications. For example, a program that determines the winner ofa sales contest inputs the number of units sold by eachsalesperson. The salesperson who sells the most units wins thecontest. Write a pseudocode program, then a C++ program that uses awhile statement to determine and print the largest numberof 10 numbers input by the user and the smallest number. Yourprogram should use three variables, as follows:
counter:
A counter to count to 10 (i.e., to keep track ofhow many numbers have been input and to determine when all 10numbers have been processed).
number:
The current number input to the program.
largest:
The largest number found so far.
so far I have this:
counter:
A counter to count to 10 (i.e., to keep track ofhow many numbers have been input and to determine when all 10numbers have been processed).
number:
The current number input to the program.
largest:
The largest number found so far.
Explanation / Answer
#include using std::cout; using std::cin; using std::endl; //function main begins program execution int main() { int counter; int number; int largest; int smallest; counter=0; largest=0; smallest=0; /* if smallest is zero, and yournumbers are greater than zero, then zero will always remain thesmallest */ coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.