ProgrammingHardGATE CS · Campus placements
How many subsets of {0, 1, 2, 3, 4, 5} contain exactly three elements?
- A. 15
- B. 20
- C. 18
- D. 30
Correct answer: B. 20
Choosing 3 of 6 elements gives C(6,3) = 20 subsets. Counting each mask of 6 bits with popcount 3 gives the same number.
More C Programming questions
- #define DOUBLE(x) (x + x). What does printf("%d", DOUBLE(2) 3) print?
- uint8t x = 0x90; uint8t y = x & (uint8t)(x - 1); What is y?
- int f(int n) { if (n == 0) return 0; return n % 2 + f(n / 2); } What is f(37)?
- For unsigned int i = 3; i >= 0; i--, what happens to the loop body?
- char a[] = "hi"; char b[] = "hi"; What does a == b evaluate to?
- What does printf("%d", '0' < '9') print?