Assignment_1_Solutions (1)

# Assignment_1_Solutions (1) - 2-15 The value of M when by i...

This preview shows pages 1–2. Sign up to view the full content.

2-15) The value of M when by: i) reference is 2 ii) value-result is 3. Explanation: By-reference : 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 . By-value-result: 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. 2-16) 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):

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.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern