ProgrammingHard

long long x = 1LL << 40 >> 39; printf("%lld", x); What is printed?

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

Correct answer: D. 2

The shift left by 40 gives 2^40, and shifting right by 39 gives 2. Using a long long keeps the value in range.

More C Programming questions

Exams that ask this topic