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

int aMl10, 20, 30) int k = 2; sub(aM[k],k); print (main\', k, aM[0] aM, aM[2]);

ID: 3587562 • Letter: I

Question

int aMl10, 20, 30) int k = 2; sub(aM[k],k); print (main', k, aM[0] aM, aM[2]); void sub(int x, int y) printf('sub', x, y); Trace and show the output produced by the code using the following parameter transmission schemes: a. by value b. by true reference c. by copy-restore reference d. by name Problem a. by value Problem b. by true ref main aM 10 20 30 aM 10 20 30 k 2 k 2 sub x Output: sub sub main main Problem c. by copy-restore Problem d. by name main aM 10 20 30 aM 10 20 30 k 2 k2 sub x Output: sub sub main main

Explanation / Answer

Answer is option a (Call By value)

In call by value, you evaluate arguments in function call , retrieving values that are then passed to the function .

i.e

function call : sub(aM[k],k) === sub(30,2) then it calls the defination of the sub function,maps the values to formal parametes x,y .

Clearly here we are calling that funciton with arguments as values .