Difficulty: Medium
Correct Answer: 1, 0, 1, 1
Explanation:
Introduction / Context:
C's logical operators use short-circuit evaluation and defined precedence: && (logical AND) has higher precedence than || (logical OR). Any nonzero integer is treated as true, and zero is false. This problem checks your command of precedence and short-circuit semantics.
Given Data / Assumptions:
Concept / Approach:
Evaluate expressions respecting precedence, then apply short-circuiting: for A || B, if A is true, B is not evaluated; for A && B, if A is false, B is not evaluated. Here, all operands are simple variables, so no side effects complicate evaluation.
Step-by-Step Solution:
Verification / Alternative check:
Manually substituting 1 for nonzero and 0 for zero reproduces the results, confirming 1, 0, 1, 1.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting that && binds tighter than ||; assuming nonzero negative values are false (they are true in C).
Final Answer:
1, 0, 1, 1.
Discussion & Comments