ProgrammingHardTCS NQT · Infosys
int x = 3; printf("%d", x << 2 | x >> 1); What is printed?
- A. 12
- B. 1
- C. 7
- D. 13
Correct answer: D. 13
Shifts bind tighter than |, so the value is (3 << 2) | (3 >> 1) = 12 | 1 = 13.
More C Programming questions
- unsigned char c = 0x80; c >>= 1; printf("%d", c); What is printed?
- uint64t big = (uint64t)0xFFFFFFFF 2; What is big?
- enum { A, B = 5, C }; What is the value of C?
- How many integers from 1 to 100 are divisible by 3 or by 5?
- How many two-digit decimal numbers have digits summing to 9?
- The sorted array is {1, 3, 5, 7, 7, 9}. What is the index of the first element greater than 7?