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

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

ID: 3769500 • Letter: 7

Question

7. 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

i=0 and a[1]=5

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote