Logical-AND Operator:  &&

logical-AND-expression :

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

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

Example

In the following example, the logical-AND operator (&&) determines if the account balance is 0 (true) and also if the account is at least three years old (false). Since they are not both true, the ExtendAccount function is not executed.

// Example of the logical-AND operator
int nAccountBalance=0, nAccountYears=1;

if ((nAccountBalance == 0) && (nAccountYears > 3)) {
     ExtendAccount();     // so, this function will not execute
}

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