Consider the procedure declaration: Procedure P (k: integer) where the…
PYQ GATE 1988
Consider the procedure declaration:
Procedure P (k: integer)
where the parameter passing mechanism is call-by-value-result. Is it correct if the call, P (A[i]), where A is an array and i an integer, is implemented as below.
1. create a new local variable, say z;
2. assign to z, the value of A [i];
3. execute the body of P using z for k;
4. set A [i] to z;
Explain your answer. If this is incorrect implementation, suggest a correct one.
Sign up free to check your answer
Sign up freeLoading lesson…

