ProgrammingVery hard

With 32-bit unsigned arithmetic, what does (unsigned)-5 >> 1 print?

  1. A. 2147483646
  2. B. 2147483647
  3. C. 2147483645
  4. D. 4294967291

Correct answer: C. 2147483645

(unsigned)-5 is 4294967291. Shifting right by one gives 2147483645. Using signed -5 >> 1 would be implementation-defined.

More C Programming questions

Exams that ask this topic