ProgrammingModerateInfosys · C

What is printed?

What is printed?
printf("%d %d", 6 & 3 << 1, ~5 + 1);
  1. A. 2 -5
  2. B. 6 -5
  3. C. 6 -4
  4. D. 2 -6

Correct answer: B. 6 -5

Shift binds tighter than &, so 6 & (3 << 1) = 6 & 6 = 6; ~5 is -6 in two's complement, and -6 + 1 = -5.

More C Programming questions

Exams that ask this topic