Boolean Operators

Boolean Operators (Deal with conditions)
1. AND
2. OR
3. NOT

AND inside an IF:

if (C1 && C2)
{
do this
}

AND (&&) Connects two boolean expressions into one. Both expressions must be true for the overall expression to be true.

OR inside an IF:

if(C1||C2)
{
do this
}

OR (||) connects two boolean expressions into one. One or both expressions must be true for the overall expressions to be true. It is only necessary for one to be true. and it does not matter which one.

NOT inside an IF:

if(!C1)
{
do this
}

IF(A!=B)
{
do this
}

NOT(!) operator reverse the truth of a Boolean expression. if it is applied to an expression that is true. the operator returns false. If it is applied to expression that is false, the operators return true.

Advertisements

Leave a Reply