Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Even or odd number

/* Program to check whether the input integer number 
 * is even or odd using the modulus operator (%)
 */
#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;
}
Source by beginnersbook.com #
 
PREVIOUS NEXT
Tagged: #Even #odd #number
ADD COMMENT
Topic
Name
5+1 =