**What are bitwise and logical operators in C ?**

First time here? Checkout the FAQ!

x

**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 :

- ~ to perform bitwise NOT operation.
- & to perform bitwise AND operation.
- | to perform bitwise OR operation.
- ^ to perform bitwise EXOR operation.
- << to perform bitwise left shift operation.
- >> to perform bitwise right shift operation.

These operators are use to perform bitwise binary

operations on the data.

As we have addition, subtraction operations in

decimal data for performing arithmetic operations;

similarly AND, OR, NOT are basic bitwise operations

on the binary data.

**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.