C PROGRAM TO CHECK WHETHER A NUMBER IS EVEN OR ODD

Check whether a number is even or odd using modulus operator.


#include<stdio.h>

int main()
{

   int num;

   printf("Enter an integer: ");

   scanf("%d",&num);


   if ( num%2 == 0 )
      printf("%d is an even number", num);
   else
      printf("%d is an odd number", num);

   getch();
}


No comments:

Post a Comment