ProgrammingVery hardWipro NLTH · C · Advanced

What is printed?

What is printed?
uint8_t x = 0xA5;
x = (x << 4) | (x >> 4);
printf("%d %d", x, (uint8_t)~x);
  1. A. 165 90
  2. B. 90 -91
  3. C. 2650 165
  4. D. 90 165

Correct answer: D. 90 165

The int result 0xA5A is truncated to 8 bits, 0x5A = 90 (a nibble swap); ~x is computed on the promoted int and the cast keeps the low byte, 0xA5 = 165.

More C Programming questions

Exams that ask this topic