Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions

Question

What is the orientation toward time?

Answered: 1 week ago

Question

4. How is culture a contested site?

Answered: 1 week ago