(a) What type of parameter passing mechanism (call-by-value,…
PYQ GATE 1992
(a) What type of parameter passing mechanism (call-by-value, call-by-reference, call-by-name, or-by-value result) is the following sequence of actions truing to implement for a procedure call P (A[i]) where P (i:integer) is a procedure and A is an integer array?
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 A[i]
4. Set A[i] to z.
Is the implementation correct? Explain and correct it if necessary. You are supposed to make only small changes.
(b) Show the activation records and the display structure just after the procedures called at lines marked x and y have started their execution. Be sure to indicate which of the two procedures named A you are referring to.
Program Test;
Procedure A;
Procedure B;
Procedure A;
......
end a;
begin
y:A;
end B;
begin
B;
end A;
begin
x:A;
end Test.
Sign up free to check your answer
Sign up freeLoading lesson…

