0

i was given this question by my instructor and i am completely in the dark on what to do. i have been trying to figure out what to do but couldn't find anything in the book that really explained it. any help with this would be greatly appreciated.

explain what is happening in the pseudo code LOOP in one word. What is temp referring, 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

I think temp refers to the temporary variable but i can't figure out what she means by the first sentence. how do i get the final output?
thanks again for any help you may be able to give me

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by minas1
0

i'm not sure, thats why i am asking. i'm not sure what to do with the numbers to figure out the answer

0

:= looks like shorthand for assign. The rest seems pretty much straightforward.

Input n values, n = 5 in this case
assign the first value to temp
for the rest of the values
//you can do the rest.

0

:= looks like shorthand for assign. The rest seems pretty much straightforward.

Exactly. It's the assignment operator in PASCAL and used in pseudocode as well.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.