The results returned by functions under value-result and reference…

2002

The results returned by functions under value-result and reference parameter-passing conventions:

Answer: D. May differ in the presence of exceptionsIn call by value-result (copy-in/copy-out), the actual argument is copied into the formal parameter at procedure entry, and the final formal value is copied…

  1. A.

    Do not differ

  2. B.

    Differ in the presence of loops

  3. C.

    Differ in all cases

  4. D.

    May differ in the presence of exceptions

Attempted by 49 students.

Show answer & explanation

Correct answer: D

In call by value-result (copy-in/copy-out), the actual argument is copied into the formal parameter at procedure entry, and the final formal value is copied back only when the procedure exits normally. In call by reference, the formal parameter is an alias of the actual argument, so updates are made directly as the procedure executes. Therefore, under normal execution without aliasing, the final result can be the same, but in the presence of exceptions or abnormal termination, value-result may not perform the copy-out step whereas reference passing may already have changed the actual value. Hence the results may differ in the presence of exceptions.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…