C Program to check if number is even or odd

 #include<stdio.h>

int main()
{
   // This variable is to store the input number 
   int num;
 
   printf("Enter an integer: ");
   scanf("%d",&num);
 
   // Modulus (%) returns remainder
   if ( num%2 == 0 )
      printf("%d is an even number", num);
   else
      printf("%d is an odd number", num);
 
   return 0;
}

Output:



Comments

Popular posts from this blog

Program to find the average of two numbers

Program to add two integer numbers