ProgrammingModerate
printf("%d", !5 + !0); What is printed?
- A. 0
- B. 1
- C. 2
- D. 6
Correct answer: B. 1
! yields 1 for a zero operand and 0 for any nonzero one, so !5 = 0 and !0 = 1, giving 1. 2 wrongly takes !5 as 1, and 6 ignores the first ! entirely.
More C Programming questions
- 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?
- printf("%d", (-17 % 5 + 5) % 5); What is printed in C99?