Saturday, 18 March 2017

C Program to check if the given number is Odd or Even

C Program to check if a the given number is Odd or Even is given below. Approach is simple we will use modulus operator to check if a number is even or odd. Example is given below.


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

   printf("\nEnter the number: ");
   scanf("%d",&number);

   if(number%2==0)
   {
        printf("\nThe given number is an even number");
   }
   else
   {
        printf("\nThe given number is an odd number");
   }
   printf("\n");
   return 0;
}


OUTPUT:

 


EmoticonEmoticon