Question: Using C. Please fill out the code and do not make modifications to the functions or headers : #include #include int foo(int* a, int* b,
Using C. Please fill out the code and do not make modifications to the functions or headers :
#include #include
int foo(int* a, int* b, int c){ /*Swap the addresses stored in the pointer variables a and b*/ /*Decrement the value of integer variable c*/ /*Return c*/ }
int main(){ /*Declare three integers x,y and z and initialize them randomly to values in [0,10] */ /*Print the values of x, y and z*/ /*Call foo() appropriately, passing x,y,z as parameters*/ /*Print the values of x, y and z*/ /*Print the value returned by foo*/ return 0; }

1) The function int foo(int *a, int *b, int c) should perform the following computations -Swap the addresses of the integers pointed to by a and b (not the values of the integers pointed to by a and b). - Decrement the value of c - Return the value of c. ) In the main function, declare three integers x, y, and z, and assign them random integer values in the interval [O, 10] 3) Print the values of the integers x, y, and z. Call foo() appropriately passing x, y, and z as arguments. Print out the values of integers x, y, and z after calling the function foo(.). Also, print the value returned by foo(). 4) Answer the following questions in a comment at the bottom of the file: a) Is the return value different than the value of integer z? Why or why not? b) Are the values of integers x and y different before and after calling the function foo(.)? Why or why not
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
