ProgrammingHard

What is the value of 2 + 3 << 1 & 7 in C?

  1. A. 10
  2. B. 2
  3. C. 7
  4. D. 0

Correct answer: B. 2

Addition binds tighter than the shift, and the shift tighter than &. So it is ((2 + 3) << 1) & 7 = 10 & 7 = 2.

More C Programming questions

Exams that ask this topic