ProgrammingModerate
What is printed by printf("%d", 0x7FFFFFFF + 0);?
- A. -2147483648
- B. 0
- C. 2147483647
- D. undefined behaviour
Correct answer: C. 2147483647
Adding zero cannot overflow, so the value is INT_MAX, 2147483647.
More C Programming questions
- What value is -x when x is 7 in two's complement, expressed as ~x + 1?
- What is the value of (unsigned short)(65535 + 1) on a platform where unsigned short is 16 bits?
- 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?