Blog Moved

This website completely moved to new domain. For latest content, visit

Search This Blog

24 Jul 2012

C Program to find Number Even or Odd using Bitwise AND ( & ) Operator

c program to understand the usage of Bitwise Operator & .
Example c program for Bitwise operator & ..


    int n,i;

    printf("\n Enter a Integer Number to find Even or Odd:");
    i=!(n&1);  /* & is a bitwise and operator*/
    if ((i))
        printf("\n The Entered Number Is Even");
       printf("\n The Entered Number is Odd");


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

      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


  1. C program to check odd or even

    In general Even numbers are those which are divisible by 2, and which numbers are not divisible 2 is called odd numbers.
    We can easily write even odd program in c programming.

  2. 7 easy ways to find whether a number id odd/even.