Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Bitwise Operation Explanation in C

Bit wise & operator performs the below:

For example if you have value 1, 3 to perform bit wise operation, you can visualise like below:
Input : 3 & 1
Odd number : 3
1 - 0001
3 - 0011 & operation
-----------
1- 0001 -- this is resultant of & operation


For example if you have value 1, 2 to perform bit wise operation, you can visualise like below:

Input : 2 & 1
Even number : 2 & 1
1 - 0001
2 - 0010 & operation
-----------
0- 0000 -- this is resultant of & operation

Another example illustrated below :
Inputs : 1003 & 1
001111101011 & 000000000001 = 000000000001

Example Program:
#include<stdio.h>
 
int main()
{
   int n;
 
   printf("Enter an integer\n");
   scanf("%d",&n);
 
   if ( n & 1 == 1 )
      printf("Odd\n");
   else
      printf("Even\n");
 
   return 0;
}