ProgrammingHardGATE CS · Campus placements

What does (unsigned int)(-1) % 10 evaluate to on a platform with a 32-bit unsigned int?

  1. A. 9
  2. B. 4
  3. C. 5
  4. D. 1

Correct answer: C. 5

(unsigned int)(-1) is 4294967295, and its last digit is 5, so the remainder is 5. Applying the negation after the modulo would give a different answer.

More C Programming questions

Exams that ask this topic