ProgrammingHardGATE CS · Infosys

What is printed?

What is printed?
#include <stdint.h>
#include <stdio.h>
int main(void) {
    uint32_t x = 0x00F0u;
    printf("%u", x & (0u - x));
}
  1. A. 16
  2. B. 240
  3. C. 256
  4. D. 15

Correct answer: A. 16

x & -x keeps only the lowest set bit, which for 0xF0 is 0x10 = 16. The value 240 is x itself and 15 is the lowest set bit's mask.

More C Programming questions

Exams that ask this topic