ProgrammingHardGATE CS · Campus placements
How many integers from 0 to 255 have exactly four 1 bits in binary?
- A. 56
- B. 64
- C. 70
- D. 28
Correct answer: C. 70
Choosing 4 of the 8 bit positions gives C(8,4) = 70 values, each one a different byte.
More C Programming questions
- What is 0 ^ 1 ^ 2 ^ ... ^ 31, the XOR of all integers from 0 to 31?
- What is the total number of 1 bits in the binary forms of 1, 2, ..., 16 added together?
- uint16t s = 0; for (int i = 1; i <= 1000; i++) s += i; What is s at the end?
- #define CAT(a,b) a##b. After int CAT(num, 2) = 7; what does printf("%d", num2 2) print?
- int a = 1 ? 2 : 3 ? 4 : 5; What is a?
- char p = "xyz"; char a[] = "xyz"; a[0] = 'Q'; printf("%s", a); What is printed?