Question
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
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
Answers
bobpursley
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.
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.
thanks for the help
Related Questions
I have just started a basic class in programming and I am totally lost. Can someone help me out? I h...
Hi. I am working on my Final Project for my medical billing class. I am filling out a CMS-1500 form....
Here is the question that I need help to write the code for the following program in Visual Basic 20...
Hi, I have this question to answer and I am just really confused I don't know where to begin we have...