Please see the attached file.
1.
Let the function fun be defined as
Int fun(int *k) {
*k +=4;
Return 3 * (*k) -1;
}
Suppose fun is used in a program as follows:
Void main() {
Int i = 10, j = 10, sum1, sum2;
Sum1 = (i/2) + fun(&i);
Sum2 = fun(&j) + (j/2);
What are the values of sum1 and sum2
a. if the operands in the expressions are evaluated left to right?
b. if the operands in the expressions are evaluated right to left?
2.
Consider the following C program:
Int fun(int *i) {
*i+= 5;
Return 4;
}
Void main() {
Int x = 3;
X = x + fun(&x);
}
What is the value of x after the assignment statement in main, assuming
a. operands are evaluated left to right.
b. operands are evaluated right to left.
Using pointers in C++ functions to understand how to pass parameters by value and by reference.