ProgrammingVery hardGATE CS · Campus placements

unsigned char c = 0xFF; unsigned int u = c << 8 | c; printf("%X", u); What is printed?

  1. A. FFFF
  2. B. FF00
  3. C. 00FF
  4. D. FFFF00

Correct answer: A. FFFF

c << 8 is 0xFF00 in int, and OR-ing with c keeps the low byte, giving 0xFFFF. Shifts bind tighter than |, so the grouping is correct.

More C Programming questions

Exams that ask this topic