ProgrammingVery hard
printf("%d", 1 && 0 || 2); What is printed?
- A. 1
- B. 0
- C. 2
- D. 3
Correct answer: A. 1
&& binds tighter than ||, so the result is (1 && 0) || 2, and the logical OR yields 1, not 2.
More C Programming questions
- 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?
- printf("%d %d", -17 % 5, 17 % -5); What is printed in C99?