Bitwise OR (  ) Operator in C programming Language
Bitwise OR:
 The output of Bitwise OR is true if anyone of the Input is true. Otherwise, the output is 0.
 In other words, Output of Bitwise OR is zero only on each and every Input is Zero, Otherwise, the output will be one.
 Bitwise OR is denoted with “  ”.
Here is the Truth Table for Bitwise OR:
INPUT 1

INPUT 2

OUTPUT

0

0

0

0

1

1

1

0

1

1

1

1

Example to Understand the Bitwise OR operator:
Example program to Understand Bitwise OR (  ) Operator :

#include<stdio.h>

int main()

{

int a,b;

a=10,b=20;

printf(“bitwise OR of A and B (ab) : %d n”,a  b);

return 0;

}
Output :
bitwise OR of A and B (ab) : 30
Note:Bitwise OR is completely different from Logical OR. Logical OR works on byte level, on other hand Bitwise OR is works on BitLevel.
Program to Understand Difference between Bitwise OR and Logical OR :

#include<stdio.h>

int main()

{

int a,b;

a=10;

b=20;

printf(” Bitwise OR of A and B is ( A  B) : %d n“, ab );

printf(” Logical OR of A and B is ( A  B) : %d n“, ab );

return 0;

}
Bitwise OR of A and B is ( A  B) : 30 Logical OR of A and B is ( A  B) : 1
Quick tips on Bitwise OR Operator:
1 2 3 4 5 6 
#include <stdio.h> int main() { Printf(“Result is : %d n”, 0  431); return 0; } 
431
1 2 3 4 5 6 7 
#include<stdio.h> int main() { Printf(“Result is : %d n”, 1  431); return 0; } 
1
Also Read :
 Arithmetic Operators with Examples.
 Arithmetic operators priority and it’s Associativity.
 Modulus Operator and Hidden Concepts of Modulus Operator.
 Precedence Table or Operators Priority Table.
 Assignment Operator, Usage, Examples
 Increment Operator and Different types of Increment operators Usage with Examples.
 Decrement Operator and Different types of Decrement operators with Examples.
 Logical Operators tutorial with Examples.
 Relational Operators Tutorial with Examples.
 Conditional Operator tutorial and In depth analysis.
 Bitwise operators Tutorial.
 Comma Operator Tutorial.
2 Responses
[…] Bitwise OR (  ) […]
[…] Bitwise OR (  ) […]