Let the function fun be defined as int fun( int *k) { *k += 4; return 3 *(*k) -1
ID: 3616230 • Letter: L
Question
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 toright? b. if the operands in the expressions are evaluated right toleft? 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 toright? b. if the operands in the expressions are evaluated right toleft?
Explanation / Answer
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); } a. if the operands in the expressions are evaluated left toright?
i j sum1 sum2 in fun k
10 10 5+ 41 41+7 10
14 14 14
10
14
sum1=46 sum2=48
b. if the operands in the expressionsare evaluated right to left?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.