ProgrammingVery hard
What is 1 ^ 2 ^ 3 ^ 4 ^ 5 ^ 6 ^ 7 ^ 8 ^ 9 ^ 10 in C?
- A. 10
- B. 11
- C. 9
- D. 0
Correct answer: B. 11
The XOR of 1 through n depends on n mod 4. For n = 10, n mod 4 = 2, which gives n + 1 = 11.
More C Programming questions
- What is the Hamming distance between 13 and 22 (the number of bit positions where they differ)?
- unsigned int a = 3, b = 5; printf("%u", a - b + 3); What is printed on a 32-bit platform?
- printf("%d", -1 < 1u); What is printed?
- What is the number of subsets of {0, 1, 2, 3, 4} whose element sum is even (the empty set counts)?
- The Gray code 0b110 is converted to ordinary binary using the prefix XOR rule. What is the decimal result?
- What does printf("%d", 8 & 7 == 0); print?