ProgrammingModerateTCS NQT · Infosys

How many integers i with 1 <= i <= 100 have bit 3 (value 8) set in their binary form?

  1. A. 50
  2. B. 36
  3. C. 52
  4. D. 48

Correct answer: D. 48

Bit 3 repeats in blocks of 16, with 8 set in every second block. Numbers 1 to 96 contain six full blocks, giving 48, and 97 to 100 add none.

More C Programming questions

Exams that ask this topic