ProgrammingHard

printf("%d", (5 & 3) << 2 | 1); What is printed?

  1. A. 5
  2. B. 4
  3. C. 7
  4. D. 1

Correct answer: A. 5

The shift binds tighter than &, and | is lowest. So (5 & 3) << 2 = 4, and 4 | 1 = 5.

More C Programming questions

Exams that ask this topic