ProgrammingHardGATE CS · Competitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned x = 0xDEADu;
    printf("%u", (x >> 3) & 0xFu);
}
  1. A. 13
  2. B. 6
  3. C. 7
  4. D. 5

Correct answer: D. 5

0xDEAD >> 3 is 0x1BD5, and masking the low nibble gives 5. Using the bits starting at position 4 would give a different nibble.

More C Programming questions

Exams that ask this topic