Computer Science, asked by shadowkingt0321, 2 months ago

What will be the values after execute the following java expression.
a) int c=0,a=5,b=3;
c= (++a) + (b++) + 4; Find the value of a,b,c
b) int x=0,y=9,h=4;
x= (y++) + (- -h) + 13; Find the values of x,y,h
c) int g=2,r=6,d=1;
g=g + (- -r) + (d++) + g; Find the values of g,r,d

Answers

Answered by allysia
2

Answer:

a) a=6,b=3,c=13

b)x=25, y=10, h=3

c)g=10,r=5,d=2

Explanation:

Before you solve:

  • ++a will increase the value of the variable by 1 before taking part in an expression
  • a++ will participate in expression before raising the value

a) Look at c= (++a) + (b++) + 4;  as c=(6) +(3) +4  

a=6,b=3

Therefore c=13

b) Look at x= (y++) + (--h) + 13; as x = (9) + (4) + 13

x=25, y=10

Therefore h=3

c) Look at g=g + (--r) + (d++) + g; as g =2+(5)+(1) +2

r=5,d=2

Therefore g=10

Similar questions