ProgrammingHardCompetitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned mask = ~0u << 4;
    printf("%X", mask >> 28);
}
  1. A. FF
  2. B. F
  3. C. F0
  4. D. 0

Correct answer: B. F

~0u << 4 clears the low four bits, so the top nibble is still F, and shifting right by 28 leaves F. The printed value is F.

More C Programming questions

Exams that ask this topic