ProgrammingHardGATE CS · Campus placements
uint32_t x = 1u; x <<= 31; x <<= 1; What is x afterwards?
- A. 0
- B. 2147483648
- C. 4294967296
- D. 1
Correct answer: A. 0
Left shifts of an unsigned value discard bits beyond its width, so the set bit moves out of the 32-bit range. The result is 0, not undefined behaviour.
More C Programming questions
- What is the value of (uint64t)1 << 40?
- uint64t computes 3 to the power 40 modulo 1000000007 with square-and-multiply, reducing after each multiplication. What is the result?
- uint32t x = 0x7FFFFFFFu; x = x 2u + 1u; What is x?
- For an unsigned integer x, which expression clears the lowest set bit of x?
- uint8t a = 0xF0, b = 0x3C; uint8t c = a & ~b; What is c?
- uint16t a = 3, b = 5; printf("%d", (a - b) > 0); prints what?