Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (6 points) Consider the following function written in C: int x=3, y=2, z=1; void foo(int a, int b) { x = x + b;

image text in transcribed

1. (6 points) Consider the following function written in C: int x=3, y=2, z=1; 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(y,z) where all parameters are passed by reference (c) foo(y,z) where all parameters are passed by value-result (d) foo(x,y) where all parameters are passed by reference (e) foo(x,x) where all parameters are passed by reference (f) foo(x,x) where all parameters are passed by value-result

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

More Books

Students also viewed these Databases questions