Multiple choice

Consider the following code. What will be the values of a, x, y and z? main() {
int x=10,y=20,z=30,a=0; clrscr();
a=(x+=y)||(y+=z);
getch(); }

  1. a=0, x=10, y=20, z=30

  2. a=1, x=30, y=50, z=30

  3. a=0, x=30, y=50, z=30

  4. a=1, x=30, y=20, z=30

  5. a=1, x=10, y=50, z=30

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

X+=y gives 30, which is a non zero value and logical or operator returns 1, when there is atleast one non zero value. Thus retrieving a non zero value already terminates before calculating y+=z.