ProgrammingModerateTCS NQT · Infosys
What does printf("%d", 10 / 3 * 3 == 10) print?
- A. 0
- B. 1
- C. 3
- D. 10
Correct answer: A. 0
10 / 3 truncates to 3, so the left side is 9 and 9 == 10 is false. Integer division loses the remainder before the multiplication.
More C Programming questions
- int x = 3; printf("%d", x << 2 | x >> 1); What is printed?
- 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?