C Program to understand the usage of Bitwise Operator & .
(Or)
Example c program for Bitwise operator & .
PROGRAM:

 

Sample Output: (using GNU GCC Compiler with Code Blocks IDE)
1) Enter a Integer Number to find Even or Odd: 5
The Entered Number is Odd
2) Enter a Integer Number to find Even or Odd:
The Entered Number Is Even
Explanation :
      n       1     (n&1)     !(n&1)
n=2  0010   0001    0000      returns 1 ( if statment executes)    
n=3  0011   0001    0001      returns 0 ( else statment executes)
Truth Table:
    p    q     p&q
    0    0      0
    0    1      0
    1    0      0
    1    1      1

Leave a Reply

Your email address will not be published. Required fields are marked *