Examveda
Examveda

int x = 0, y = 0 , z = 0 ;
x = (++x + y-- ) * z++;

What will be the value of "x" after execution ?

A. -2

B. -1

C. 0

D. 1

E. 2

Answer: Option C


This Question Belongs to Java Program >> Operators

Join The Discussion

Comments ( 3 )

  1. Prashanthi Chandamala
    Prashanthi Chandamala :
    3 years ago

    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

  2. Gaddapara Swapna
    Gaddapara Swapna :
    6 years ago

    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).

  3. NETHRA K
    NETHRA K :
    8 years ago

    x = (++x + y--)*z++ i.e., x = (1 -1)*0 = 0

Related Questions on Operators