ProgrammingModerateTCS NQT · Infosys

What is printed?

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

Correct answer: A. 13

0x16D is 1 0110 1101 in binary, and keeping the low four bits with & 0xF leaves 1101, which is 13.

More C Programming questions

Exams that ask this topic