ProgrammingHardTCS NQT · Infosys

unsigned char x = 0; x--; What is x?

  1. A. -1
  2. B. 0
  3. C. 256
  4. D. 255

Correct answer: D. 255

Decrementing an unsigned char wraps modulo 256, so 0 - 1 becomes 255. Unsigned small types follow the same modular rule as larger unsigned types.

More C Programming questions

Exams that ask this topic