Logical-OR Operator:  ||

logical-OR-expression :

logical-AND-expression
logical-OR-expression **||**logical-AND-expression

The logical operators, logical-AND (&&) and logical-OR (||), are used to combine multiple conditions formed using relational or equality expressions. The logical-OR operator (||) returns the integral value 1 if either operand is nonzero; otherwise, it returns 0. Logical-OR has left-to-right associativity.

Example

In the following example, the logical-OR operator (||) determines if either switch setting is true. Since nSw1 is true, AnyFunction() will execute.

// Example of the logical-OR operator
int nSw1=1, nSw2=0;

if (nSw1 || nSw2) {  // nSw1 is true while nSw2 is not true
     AnyFunction();  //  so, this function will execute
}

For related information, see logical-AND and logical-NOT.