The process of finding the largest value (i.e., the maximum of a group of values
ID: 3586999 • Letter: T
Question
The process of finding the largest value (i.e., the maximum of a group of values) is used frequently in computer applications. For example, a script that determines the winner of a sales contest would input the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write a pseudocode algorithm and then a script that inputs a series of 10 single- digit numbers as characters, determines the largest of the numbers and outputs a message that displays the largest number. Your script should use three variables as follows:
a) 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);
b) number: The current digit input to the script;
c) largest: The largest number found so far.
Explanation / Answer
PseudoCode
count = 10
number = ' '
largest = -INF
while count > 0
number = input("Enter a number")
if number > largest
largest = number
count = count - 1
end
print "largest number is" , largest
Thanks, let me know if there is any doubts
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.