ProgrammingHardTCS NQT · Infosys
What is the value of 1 + 2 * 3 << 1 in C?
- A. 8
- B. 7
- C. 14
- D. 12
Correct answer: C. 14
Multiplication binds first, then addition, and shifts bind last: (1 + 6) << 1 = 14. Shifts sit below additive operators in the precedence table.
More C Programming questions
- How many positive divisors does 40 have?
- int next(void) { static int c = 0; return ++c; } Each of three calls returns its value, and the three returns are added together. What is…
- char s[] = "a0b"; What is strlen(s)?
- uint32t v = 0; for each digit d of the decimal string "4294967296", v = v 10 + d; What is v at the end?
- Using fib-like recursion where a stair can be climbed by 1 or 2 steps, the number of ways for 10 stairs is the recursion W(n) = W(n-1) +…
- What is sizeof "hi" in C?