ProgrammingHard
What is the total number of 1 bits in the binary representations of the integers 1 through 10?
- A. 17
- B. 15
- C. 19
- D. 10
Correct answer: A. 17
The counts are 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, which total 17.
More C Programming questions
- What is 1 ^ 2 ^ 3 ^ 4 ^ 5 ^ 6 ^ 7 ^ 8 ^ 9 ^ 10 in C?
- What is the Hamming distance between 13 and 22 (the number of bit positions where they differ)?
- unsigned int a = 3, b = 5; printf("%u", a - b + 3); What is printed on a 32-bit platform?
- printf("%d", -1 < 1u); What is printed?
- What is the number of subsets of {0, 1, 2, 3, 4} whose element sum is even (the empty set counts)?
- The Gray code 0b110 is converted to ordinary binary using the prefix XOR rule. What is the decimal result?