# C 逻辑运算符C Logical Operators

logical-AND-expressionlogical-AND-expression:
inclusive-OR-expressioninclusive-OR-expression

logical-AND-expression && inclusive-OR-expressionlogical-AND-expression && inclusive-OR-expression

logical-OR-expression:logical-OR-expression:
logical-AND-expressionlogical-AND-expression

logical-OR-expression| |logical-AND-expressionlogical-OR-expression || logical-AND-expression

C 逻辑运算符如下所述：The C logical operators are described below:

&& 如果两个操作数具有非零值，则逻辑“与”运算符产生值 1。The logical-AND operator produces the value 1 if both operands have nonzero values. 如果其中一个操作数等于 0，则结果为 0。If either operand is equal to 0, the result is 0. 如果逻辑“与”运算的第一个操作数等于 0，则不会计算第二个操作数。If the first operand of a logical-AND operation is equal to 0, the second operand is not evaluated.
`&#124;&#124;` 逻辑“或”运算符对其操作数执行“与或”运算。The logical-OR operator performs an inclusive-OR operation on its operands. 如果两个操作数的值均为 0，则结果为 0。The result is 0 if both operands have 0 values. 如果其中一个操作数具有非零值，则结果为 1。If either operand has a nonzero value, the result is 1. 如果逻辑“或”运算的第一个操作数具有非零值，则不会计算第二个操作数。If the first operand of a logical-OR operation has a nonzero value, the second operand is not evaluated.

## 示例Examples

``````int w, x, y, z;

if ( x < y && y < z )
printf( "x is less than z\n" );
``````

``````printf( "%d" , (x == w || x == y || x == z) );
``````