Bitwise Operators:
- Bitwise operators are used to manipulate the data at bit level.
- They can be applied only to char and int types.
- The operators are
- Bitwise – AND (&)
- Bitwise – OR (|)
- Bitwise – XOR(^)
These operators first convert the data into corresponding binary form and then perform the operations according to truth table.
| A | B | A&B | A|B | A^B |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
#include<stdio.h>
int main()
{
int a=15,b=8,c,d,e;
c = a & b ;
d = a | b ;
e = a ^ b ;
printf("%d,%d,%d",c,d,e);
return 0;
}
Output this:
#include<stdio.h>
int main()
{
int i=32, j=0x20, k, l, m;
k=i|j;
l=i&j;
m=k^l;
printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);
return 0;
}