> For the complete documentation index, see [llms.txt](https://mun.gitbook.io/c/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mun.gitbook.io/c/c/ch2/bitwise-operators.md).

# Bitwise Operators

<table data-header-hidden><thead><tr><th width="116">Operator</th><th width="295">Description</th><th width="99">Example</th><th width="131">Evaluation</th><th>Result</th></tr></thead><tbody><tr><td>Operator</td><td>Description</td><td>Example</td><td>Evaluation</td><td>Result</td></tr><tr><td>&#x26;</td><td>Bitwise AND between the left and right Operands. (Consider Both Operand Value in Binary)</td><td>12 &#x26; 5</td><td><p>00001100</p><p>00000101</p><p>00000100</p></td><td>4</td></tr><tr><td>|</td><td>Bitwise OR between the left and right Operands. (Consider Both Operand Value in Binary)</td><td>12 | 5</td><td><p>00001100</p><p>00000101</p><p>00001101</p></td><td>13</td></tr><tr><td>^</td><td>Bitwise EXCLUSIVE OR between the left and right Operands. (Consider Both Operand Value in Binary)</td><td>12 ^ 5</td><td><p>00001100</p><p>00000101</p><p>00001001</p></td><td>9</td></tr><tr><td>~</td><td>Bitwise COMPLEMENT of the Operand. (Consider Operand Value in Binary)</td><td>~12</td><td><p>00001100</p><p>  11110011</p><p>  01110011<br>00001100<br>00000001<br>00001101</p></td><td>13</td></tr><tr><td>&#x3C;&#x3C;</td><td>Bitwise LEFT SHIFT of the left operand, Number of bit(s) to be shifted to be defined by the right Operand. (Consider Left Operand Value in Binary)</td><td>12&#x3C;&#x3C;2</td><td><p>00001100</p><p>0000110000</p></td><td>48</td></tr><tr><td>>></td><td>Bitwise RIGHT SHIFT of the left operand, Number of bit(s) to be shifted to be defined by the right Operand. (Consider Left Operand Value in Binary)</td><td>12>>2</td><td><p>00001100</p><p>00000011</p></td><td>3</td></tr></tbody></table>

```c
#include<stdio.h>
int main(){
   
    printf("12 & 5 Evaluated %d\n", 12 & 5);
    printf("12 | 5 Evaluated %d\n", 12 | 5);
    printf("12 ^ 5 Evaluated %d\n", 12 ^ 5);
    printf("~12 Evaluated %d\n", ~12);
    printf("12<<2 Evaluated %d\n", 12<<2);
    printf("12>>2 Evaluated %d\n", 12>>2);

    return 0;
}
```

```c
#include<stdio.h>
int main(){
    
    printf("%d %d\n", 0, ~0);
    printf("%d %d %d\n", 3, 5, 3 | 5);
    printf("%d %d %d\n", 3, 2, 3<<2);
    printf("%d %d %d\n", 12, 2, 12>>2);

    return 0;
}
```

```c
#include<stdio.h>
int main(){
    int a = 10;

    a = 10;
    printf("%d | 1 = %d\n", a, a | 1);
    
    a = 10;
    printf("%d & 1 = %d\n", a, a & 1);
    
    a = 11;
    printf("%d & 1 = %d\n", a, a & 1);
    
    a = 10;
    printf("%d ^ 1 = %d\n", a, a ^ 1);

    return 0;
}

```
