Logical Operators In C++

Card image cap

Logical Operator ?

Logical operator allow a program to make a decision based on multiple conditions. Each operand is considered a condition that can be evaluated to a true or false value.


Then the value of the conditions is used to determine the overall value of the op1 operator op2 or !op1 grouping.

The && operator is used to determine whether both operands or conditions are true and.pl.

The || is used to determine whether either of the conditions is true.

The ! operator is used to convert true values to false and false values to true.


Card image cap

Logical Operators

Operator Description
&& And operator. if both expressions evaluate to True, result is True. If either expression evaluates to False, result is False
|| Or operator. if either or both expressions evaluate to True, result is True
! Not operator. Performs logical negation on an expression.

Card image cap

Example :



Output :

OR If Block Gets Executed
AND If Block Gets Executed
NOT If Block Gets Executed
Card image cap