ProgrammingModerateGATE CS · Campus placements

What is popcount(0xFFFF0000 ^ 0x0F0F0F0F)?

  1. A. 12
  2. B. 20
  3. C. 16
  4. D. 8

Correct answer: C. 16

The XOR is 0xF0F00F0F, which has four nibbles equal to F and four nibbles equal to 0, so it has 16 set bits.

More C Programming questions

Exams that ask this topic