int x = 0, y = 0 , z = 0 ;
x = (++x + y-- ) * z++;
What will be the value of "x" after execution ?
int x = 0, y = 0 , z = 0 ;
x = (++x + y-- ) * z++;
A. -2
B. -1
C. 0
D. 1
E. 2
Answer: Option C
Initially x=0
x = (++x + y--) * z++;
++x means first it gets incremented later gets initialised //++x=1
y-- means it gets initialised first later gets decremented //y-- =-1
z++ means first it gets incremented later gets initialised //z++ =1
x=(1+ -1) * 1
x=0
x=(1+0)*0
x=1*0="0".
++x is pre increment so its value become 1.but y-- and z++ are post dcrement and post increment respectively,so their value remains same in that line(statement).
x = (++x + y--)*z++ i.e., x = (1 -1)*0 = 0