When the caller receives the result

A warehouse simulation uses value-result passing: it copies the caller's integer into a separate local parameter when a procedure starts, then copies the final local value back when the procedure returns. The caller's variable count initially holds 14 packages.


The following pseudocode uses = for assignment. The procedure is called with count as its argument.


Plain text
procedure adjust(value-result p)
    p = 3 * p
    p = p - 5
end procedure

adjust(count)


Complete the table with exact integers. Each number represents a package count. The word Discarded indicates that the local parameter no longer exists after the procedure returns.

CheckpointCaller countLocal parameter p
Immediately after copying in
After the multiplication
After the subtraction, before copying out
After the procedure returnsDiscarded

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Parameter Passing Questions: