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.
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.
Unlock full course notes by signing up
Compare two passing modes
Each table row represents a fresh, independent run of this pseudocode with caller variable x initially equal to 4. The symbol := means assignment. Use the passing mode stated in that row. Complete the final caller value and the parameter value immediately before the procedure returns. Enter exact integers.
Replacing a Java array parameter
A Java program contains the following method and caller statements. Which statements correctly describe the arrays immediately before reset reaches its end? Select every correct statement.
One shared list, then two
A data-processing script uses the same Python list for both arguments in the call below. Determine the final values of data[0], data[1], and result. Enter each as a unitless integer, to zero decimal places.
Two results competing for one destination
A stock simulation uses value-result passing. Each parameter receives its own local copy of its argument's integer at entry. Assignments update those local copies. On return, each final local value is copied back to the caller variable supplied for that parameter.
The program makes this call using the following pseudocode, where = means assignment:
Both arguments designate the same caller variable stock, initially containing 11 units. Consider two independent runs, each starting with 11 units. In one run, the procedure copies back p first and q second. In the other, it copies back q first and p second.