ProgrammingHard
What is the value of 2 + 3 << 1 & 7 in C?
- A. 10
- B. 2
- C. 7
- D. 0
Correct answer: B. 2
Addition binds tighter than the shift, and the shift tighter than &. So it is ((2 + 3) << 1) & 7 = 10 & 7 = 2.
More C Programming questions
- What is the value of 5 ^ 3 & 1 in C?
- unsigned int u = 1; int s = -2; printf("%u", u + s); What is printed with 32-bit unsigned int?
- With int a = -1 and unsigned int b = 0, what does the expression a < b evaluate to?
- Using the extended Euclidean algorithm, what is the inverse of 10 modulo 17?
- What is the number of 1 bits in 0xF0F0 (a 16-bit value)?
- An 8-bit value 0b10010110 is rotated left by 3 positions within 8 bits. What is the result in decimal?