ProgrammingHardGATE CS · TCS NQT

What is printed?

What is printed?
#include <stdint.h>
#include <stdio.h>
int main(void) {
    uint16_t x = 0xABCD;
    x = (uint16_t)((x << 4) | (x >> 12));
    printf("%X", (unsigned)x);
}
  1. A. BCDA
  2. B. ABCD
  3. C. CDAB
  4. D. DABC

Correct answer: A. BCDA

Rotating a 16-bit value left by four moves the top nibble to the bottom, giving 0xBCDA. A rotation by eight gives CDAB and a rotation right by four gives DABC.

More C Programming questions

Exams that ask this topic