ProgrammingModerate
What is the number of 1 bits in 0xF0F0 (a 16-bit value)?
- A. 4
- B. 12
- C. 8
- D. 16
Correct answer: C. 8
0xF0F0 is 1111 0000 1111 0000: each hex F contributes four 1 bits and each 0 none, so 2 x 4 = 8. 4 counts only one byte, and 16 is the width, not the popcount.
More C Programming questions
- An 8-bit value 0b10010110 is rotated left by 3 positions within 8 bits. What is the result in decimal?
- unsigned char s = 0; for (int i = 1; i <= 100; i++) s += i; printf("%d", s); What is printed?
- What is (1ULL << 40) % 1000 in C?
- For the signed integer -17, which expression gives the non-negative remainder modulo 5 in C?
- In 32-bit signed int arithmetic, what is the largest n such that the sum 1 + 2 + ... + n does not overflow?
- How many integers from 1 to 100 are divisible by 6 or by 9?