ProgrammingModerate
printf("%d %d", 7 / 2 * 2, 7 / (2 * 2)); What is printed?
- A. 7 1
- B. 6 2
- C. 7 2
- D. 6 1
Correct answer: D. 6 1
Division truncates. 7 / 2 = 3 and 3 * 2 = 6. The second expression is 7 / 4 = 1.
More C Programming questions
- printf("%d", 1 && 0 || 2); What is printed?
- printf("%d", !5 + !0); What is printed?
- printf("%d", (3 > 2) > 1); What is printed?
- printf("%d %d", 10 - 2 - 3, 2 ^ 3 ^ 1); What is printed?
- printf("%d", powmod(2, 100, 1000000007)); where powmod is standard binary exponentiation with 64-bit intermediates. What is printed?
- printf("%lld", (999999999LL 999999999LL) % 1000000007LL); What is printed?