ProgrammingHardProduct company OA

Assume 32-bit unsigned int. What is printed?

Assume 32-bit unsigned int. What is printed?
unsigned x = 0x12345678;
printf("%X", (x >> 16) | (x << 16));
  1. A. 12345678
  2. B. 56781234
  3. C. 5678
  4. D. 78563412

Correct answer: B. 56781234

x >> 16 brings the high half 0x1234 down, and x << 16 moves the low half 0x5678 up (the top bits fall off a 32-bit value). OR-ing swaps the two 16-bit halves: 0x56781234. '78563412' is a full byte reversal, a different operation.

More C Programming questions

Exams that ask this topic