ProgrammingModerateTCS NQT · Infosys

unsigned char c = 0x80; c >>= 1; printf("%d", c); What is printed?

  1. A. 128
  2. B. 0
  3. C. 32
  4. D. 64

Correct answer: D. 64

0x80 shifted right by one is 0x40, which is 64. The value is promoted to int before the shift but fits unsigned char afterward.

More C Programming questions

Exams that ask this topic