What are bitwise and logical operators in C ?
Bitwise Operator :
These operators work bitwise on a data.
They perform different operations on bits of a data
like AND, OR, EXOR and NOT.
The operators are listed below :
Logical Operators :
Logical operators follow the same truth table as
for the bitwise operators; but they are used to
check conditions instead of performing
operations on a data.
The logical operators are AND and OR. The
symbols used for these operators in C are &&
and || respectively.
For example a statement
y > 5 && y < 10; will result in “true” i.e. 1 if the value of y is greater than 5 AND less than 10, else it will result in false i.e. 0. Another example a statement y > 5 || y==2;
will result in “true” i.e. 1 if the value of y is
greater than 5 OR equal to 2, else it will result
in false i.e. 0.
Logical operators will be understood in more
details with the expressions and program
examples followed by this section.