ProgrammingHardTCS NQT · Infosys
unsigned char x = 0; x--; What is x?
- A. -1
- B. 0
- C. 256
- 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
- Which statement about the return value of strcmp is true?
- For 4-bit masks (bits 0 to 3), how many masks have both bit 0 and bit 2 set?
- What is the value of (1ULL << 63) >> 62 for uint64t arithmetic?
- uint8t a = 200, b = 250; uint8t avg = (a + b) / 2; What is avg?
- What is the value of 1 + 2 3 << 1 in C?
- How many positive divisors does 40 have?