ProgrammingVery hardGATE CS · Campus placements
How many 1 bits does 0xDEADBEEF have in binary?
- A. 22
- B. 26
- C. 24
- D. 20
Correct answer: C. 24
Counting the set bits nibble by nibble gives 24. A popcount that loops with x &= x - 1 finds the same total in one iteration per set bit.
More C Programming questions
- uint32t value = (uint32t)-1; printf("%d", value == 0xFFFFFFFFu); What is printed?
- How many index pairs i < j in the array {3, 5, 3, 5, 7} satisfy a[i] XOR a[j] == 0?
- How many integers from 1 to 30 are multiples of 8?
- A circular buffer of size n = 5 steps back from index 0 with (idx + n - 1) % n. What index results?
- A qsort comparator orders the elements in descending order. After sorting {5, 9, 2}, what is the first element?
- uint32t x = 491u; What is (x >> 3) & 7? (491 is 0x1EB.)