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 mainExplanation / 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 .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.