ProgrammingVery hardTCS NQT · Infosys

uint16_t v = 0xFFFFu; v = v << 4; What is v afterwards?

  1. A. 0xFFFF0
  2. B. 0xF000
  3. C. 0xFFF0
  4. D. 0x0FFF

Correct answer: C. 0xFFF0

v is promoted to int, so v << 4 is 0xFFFF0. Storing that in a 16-bit unsigned type keeps only the low 16 bits, giving 0xFFF0. Bits shifted out of an unsigned value are discarded, not trapped.

More C Programming questions

Exams that ask this topic