Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Let f be the following function, written in an imaginary language: void f(int j,

ID: 3769467 • Letter: L

Question

Let f be the following function, written in an imaginary language:

void f(int j, int k) {
       j++;

i--;

k = i + 2;

}

Assume that i is global to this function and that a is an array of integers. Now, suppose that the following statements are executed:

i = 1;

a[1] = 5;

f(i, a[i]);

For each of the following sets of assumptions, indicate what the values of i and a[1] will be after the call of f.

(a) j and k are passed by reference.

(b) j and k are passed by value-result.

(c) j is passed by reference and k is passed by name.

(d) j is passed by value-result and k is passed by name.

Explanation / Answer

value of i=0 and a[1]=5

(b) j and k are passed by value-result.