ProgrammingModerateTCS NQT · Infosys

How many 1 bits does 0b10101 have?

  1. A. 3
  2. B. 2
  3. C. 5
  4. D. 4

Correct answer: A. 3

10101 has three set bits at positions 0, 2 and 4, so the popcount is 3. The value is 21 in decimal.

More C Programming questions

Exams that ask this topic