This preview shows pages 1–2. Sign up to view the full content.
215) The value of M when by:
i)
reference is
2
ii) valueresult is
3.
Explanation:
Byreference
: X and y are pointing to N at the callee
AR. Hence any
change of value to either one of them (X or Y) results in an immediate
change to the value of N, and consequently to the other formal value. If
we change X, N will change and hence Y, and vise versa.
X= 1 in SUB TEST changes the value of
N at the main and Y at TEST to
be 1.
Hence, adding X to Y will result in 2 which will be stored in M
(pointed to be Z). Hence M will end up having the value
2
.
Byvalueresult:
inside TEST, the execution of
X=1 does not change N,
hence Y remains 2. When we do Z = X + Y we are adding 1 +
2 and will
end up having the value
3
upon existing the TEST subroutine.
216)
i) If the addresses are computed once, on entry at the caller, then the
program prints
10
,
20
,
11
.
Steps:
1) At the caller side:
“Call SUB (I, A(I))”
the value of the actual parameters: I is 1 and
A(1) = 10
2) at the callee side (inside SUB):
The formal actual substitution process will place the value 1 (of
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '11
 Soliman

Click to edit the document details