C - Logical and: &&

Logical and works as follows: just in case it's true if both inputs are true in all other situations the result is false. In next table you can find all possibilities:
abx
FalseFalseFalse
FalseTrueFalse
TrueFalse False
True True True
information about the table: a, b are inputs, x is result

&&

Description

par1 && par2
Used keywords: &&

Input


Output

If the first operand is false, then the second operand is not evaluated.

Examples

C

In the source code you can find the equivalent of the above table, for easier orientation at the end of each line is a comment which shows the result.
a1 = 0 && 0; // a1 = false
a2 = 0 && 1; // a2 = false
a3 = 1 && 0; // a3 = false
a4 = 1 && 1;  // a4 = true

C

Even one example in what situations we can use the operation logical and:
a && b
a && 1
10 >a && a>5

C

Other pieces of example codes:
!b && 1
a && b

You can find it in the following collections: logical operators
Languages: en hu cz sk