In C, what is the result of the expression 0 || 1 && 0?

The story behind the answer

In C, the expression 0 || 1 && 0 evaluates to 0.

The key is operator precedence: the logical AND operator && has higher precedence than the logical OR operator ||. C therefore groups the expression as 0 || (1 && 0), not (0 || 1) && 0. The inner operation, 1 && 0, is false and produces 0. The remaining expression becomes 0 || 0, which is also false and produces 0.

C treats an integer value of zero as false and any nonzero value as true in logical expressions. Although the operands here are integer constants, the logical operators produce an integer result: 0 for false and 1 for true. Thus the result is exactly 0, not merely a general “false” label.

Another important C feature is short-circuit evaluation. In a larger expression, && stops if its left operand is false, while || stops if its left operand is true. That behavior matters when operands call functions or access data. Parentheses are still the clearest way to communicate intent, especially because bitwise & and | have different precedence and behavior from logical && and ||.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: