Multiple choice

What will be the output of the following code snippet? main() {
int a=1,b=1;
clrscr();
a=++a||++b&&++a;
printf(a=%d, b=%d,a,b); getch(); }

  1. a=3, b=2

  2. a=2, b=1

  3. a=1, b=1

  4. a=1, b=2

  5. a=2, b=2

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

a=++a||++b&&++a; As we know, logical OR requires atleast one operand to be 1, ++a delivers a non zero value and hence the rest of the expression will not be evaluated and result 1 is assigned to a again.