Question: Consider the following pseudocode: int x = 1 , y = 3 , z = 5 ; void foo ( int a , int b

Consider the following pseudocode:
int x =1, y =3, z =5;
void foo ( int a , int b , int c ){
x = x + b + c ;
c = b - a ;
z = x + y ;
a = a +1;
y = c - x + b ;
printf ("%d ,% d ,% d \ n ",a ,b , c );
}
int main (){
foo ();
printf ("%d ,% d ,% d \ n ",x ,y , z );
}
What will the code print when we call the function foo() with the following parameters? If
necessary, assume that output arguments are copied back to parameters in the left-to-right
order. Please note the function foo is being called with different parameters at each of the
given questions below.
1. foo(x,x,y) where all parameters are passed by value
2. foo(x,z,y) where all parameters are passed by reference
3. foo(z,y,x) where all parameters are passed by value-result
4. foo(x,y,y) where all parameters are passed by reference

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!