C Program to check the Enter value are even or odd

Even means: value are completely divided by two
Odd means: value are completely not divided by two

program to check odd or even 

#include < stdio.h >

main()

{
   int n;

   printf("Enter an integer\n");


   scanf("%d",& n);

   if ( n%2 == 0 )
   {
      printf("Even\n");
   }
   else
   {
      printf("Odd\n");
   }

   return 0;

}

Output:
Enter an integer: 4
Even Number

We can use bitwise AND (&) operator to check odd or even, as an example consider binary of 7 (0111) when we perform 7 & 1 the result will be one and you may observe that the least significant bit of every odd number is 1, so ( odd_number & 1 ) will be one always and also ( even_number & 1 ) is zero.


C program to check odd or even using bitwise operator

#include < stdio.h >

main()

{
   int n;

   printf("Enter an integer\n");

   scanf("%d",& n);

   if ( n & 1 == 1 )

      printf("Odd\n");
   else
      printf("Even\n");

   return 0;

}


Find odd or even using conditional operator

#include < stdio.h >

main()

{
   int n;

   printf("Input an integer\n");

   scanf("%d",&n);

   n%2 == 0 ? printf("Even\n") : printf("Odd\n");


   return 0;

}

C program to check odd or even without using bitwise or
 modulus operator

#include < stdio.h >
main()
{
   int n;

   printf("Enter an integer\n");

   scanf("%d",& n);

   if ( (n/2)*2 == n )

      printf("Even\n");
   else
      printf("Odd\n");
   return 0;
}