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:
procedure revise(value-result p, value-result q) p = p + 6 q = 2 * q p = p + q end procedure revise(stock, stock)
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.
Find the final stock in units for each run. Enter exact integers. Use the specified copy-out order for each run.
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.
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.
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.
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.