ProgrammingModerateTCS NQT · Infosys
What is the value of 1 << 2 + 3 in C?
- A. 12
- B. 7
- C. 8
- D. 32
Correct answer: D. 32
Additive operators bind tighter than shift operators, so the expression is 1 << (2 + 3), which is 1 << 5 = 32. Writing (1 << 2) + 3 would give 7 instead.
More C Programming questions
- int x = 2; printf("%d", x & 1 == 1); prints what?
- uint32t x = 1u; x <<= 31; x <<= 1; What is x afterwards?
- 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?