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() { } inti 10,j=10, sum1, sum2; sum1 = (1/2)+ fun( & i); sum2=fun( &j)+(j / 2); What are the values of sum1 and sum2 If operands in the expressions are evaluated right to left?

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Please thoroughly explain how to solve

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() {
}
inti 10,j=10, sum1, sum2;
sum1 = (1/2)+ fun( & i);
sum2=fun( &j)+(j / 2);
What are the values of sum1 and sum2
If operands in the expressions are evaluated right to left?
Transcribed Image Text: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() { } inti 10,j=10, sum1, sum2; sum1 = (1/2)+ fun( & i); sum2=fun( &j)+(j / 2); What are the values of sum1 and sum2 If operands in the expressions are evaluated right to left?
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr