ProgrammingVery hard
printf("%u", (0u - 1u) % 10); What is printed with 32-bit unsigned int?
- A. 9
- B. 4
- C. 0
- D. 5
Correct answer: D. 5
Unsigned arithmetic wraps modulo 2^32, so 0u - 1u = UINT_MAX = 4294967295, and its last digit gives % 10 = 5. 0 assumes unsigned subtraction stops at 0, and 9 guesses from a trailing 9 that the number does not have.