ProgrammingModerateGATE CS · Campus placements
What is popcount(0xFFFF0000 ^ 0x0F0F0F0F)?
- A. 12
- B. 20
- C. 16
- D. 8
Correct answer: C. 16
The XOR is 0xF0F00F0F, which has four nibbles equal to F and four nibbles equal to 0, so it has 16 set bits.
More C Programming questions
- int q = NULL; if (q != NULL && q == 3) printf("yes"); else printf("no"); What is printed?
- #define ADD(a,b) a+b. What does printf("%d", 2 ADD(1,2) 3) print?
- #define HALF(x) x / 2. With int a = 5, b = 3, what does printf("%d", HALF(a + b)) print?
- char s[] = "2024"; int sum = 0; for (int i = 0; s[i] != '0'; i++) sum += s[i] - '0'; What is sum?
- int count = 0; for (int i = 1; i <= 10; i++) for (int j = i; j <= 10; j += i) count++; What is count at the end?
- A contest program must test whether n is prime for n up to 10^9 with a 1 second limit. Which method is fast enough for one query?