Homework Help


Qmy teacher gave us this question and i am totally confused on what to do

my teacher gave us this question and i am totally confused on what to do. any help would be greatly appreciated.

Explain what is happening in the pseudo code LOOP in one word. What is temp referring to, and what is the final output for this program:

input (12, 25, 11, 28, 14)
BEGIN
temp := a_1
for i = 2 to n
if temp < a_i then temp := a_i
END
print temp
thank you for any help on this problem

2 answers

This question still have no answer summary yet.
#1alexsAnswered at 2013-02-06 07:56:20
Temp is a temporary variable.

Lets see. It reads the first value, stores it in temp1, then it reads the next variable, tests it to see if it is greater than the first variable, if so, it replaces it, if not it reads the next data, and so on.
It appears to me it returns the greatest value from the set of data.
#2QuelineAnswered at 2013-02-07 07:07:30
thanks for the help
Anonymous Sign In Sign Up
Add Answer of
my teacher gave us this question and i am totally confused on what to do

Did this answer your question? If not, ask a new question.

Related Answers