ProgrammingHardTCS NQT · Infosys
int x = 2; printf("%d", x & 1 == 1); prints what?
- A. 0
- B. 1
- C. 2
- D. 3
Correct answer: A. 0
== binds tighter than &, so the expression is x & (1 == 1), which is x & 1. For x = 2 that is 0, because the low bit is clear.
More C Programming questions
- 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?
- uint8t a = 0xF0, b = 0x3C; uint8t c = a & ~b; What is c?