ProgrammingHardCompetitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned x = 0xA8;
    printf("%u", x & (0u - x));
}
  1. A. 168
  2. B. 8
  3. C. 4
  4. D. 16

Correct answer: B. 8

0xA8 = 1010 1000, and x & -x keeps only its lowest set bit, which is 8.

More C Programming questions

Exams that ask this topic