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

Recommended Answers

All 5 Replies

Wouldn't output be print ?...

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

Why don't you write this program and see the results?

:= 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.

:= 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.