ProgrammingHard
What is the value of (unsigned short)(65535 + 1) on a platform where unsigned short is 16 bits?
- A. 0
- B. 65536
- C. 65535
- D. 1
Correct answer: A. 0
65536 is converted to unsigned short by taking the value modulo 65536, which is 0.
More C Programming questions
- Which bit trick isolates the lowest set bit of an unsigned n?
- What is the parity of the number 0b1101011 (1 for odd count of set bits)?
- What is (-8) >> 1 in C if the platform uses arithmetic right shift for signed values?
- To multiply x by 2^k where x is an unsigned 32-bit value, which code is correct?
- A program uses a modulus of 10^9 + 7 and computes (a - b + MOD) % MOD for a and b in [0, MOD). Why add MOD before the %?
- What is the value of 5 & 6 | 3 in C?