Question

Question 2

Consider the following function written in C:

int x-1, y=2, z=3;

void foo (int a, int b) {

}

x = x + b;

a = a = b;

In each of the cases below, write down the values of x, y and z after the following

calls to foo(). If necessary, assume that output arguments are copied back to

parameters in the left-to-right order.

a) foo(y,z) where all parameters are passed by value

b) foo(x,z) where all parameters are passed by reference

c) foo(z,y) where all parameters are passed by value-return

d) foo(x,x) where all parameters are passed by reference

e) foo(y,y) where all parameters are passed by value-return