Logical Operators:
In
addition to the relational operators, C has the following three logical
operators.
The
logical operators && and || are used when we want to test more than one
condition and make decisions. An example is:
a
> b && x == 10
An expression
of this kind, which combines two or more relational expressions, is termed as a
logical expression or a compound relational expression. Like the simple
relational expressions, a logical expression also yields a value of one or
zero, according to the truth table as shown in table:
Logical AND:
The
logical AND ( && ) is a binary operator that evaluates to true if and
only if both of its operands are true.
Logical OR:
The
logical OR ( || ) is a binary operator that evaluates to true if and only if
either of its operands evaluate to true.
Post a Comment