ProgrammingHardTCS NQT · Infosys pattern

What is printed?

What is printed?
unsigned char x = 0xF0;
printf("%d", (x ^ 0xFF) & 0x0F);
  1. A. 0
  2. B. 15
  3. C. 240
  4. D. 9

Correct answer: B. 15

x^0xFF flips all 8 bits of x: 0xF0 -> 0x0F. ANDing with 0x0F keeps the low nibble (already 0x0F): result 0x0F = 15.

More C Programming questions

Exams that ask this topic