Answered step by step
Verified Expert Solution
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;
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started