c program to check the entered number is odd or even




This c program is to check whether a integer is odd or even. Logic behind this program is to divide the number by two until it cannot be further divisible, and check for the reminder is zero or one. for that we are using "mod operator" which divide the number until it cannot be further divisible. if the reminder is one it is odd else even.

User have to input a integer using print f and scan f statements.

Now we use mod operator to check the remainder is zero or one and print the output.

===================================================================
#include <stdio.h>
 
#include <conio.h>
 
void main()
 
{
 
   int ival, remainder;
 
   clrscr();
 
   printf("Enter an integer :");
 
   scanf ("%d", &ival);
 
   remainder = ival % 2;
 
   if (remainder == 0)
 
	printf ("%d, is an even integer\n", ival);
 
   else
 
	printf ("%d, is an odd integer\n", ival);
 
}
==================================================================
OUTPUT of C program to find odd or even-Computer program
==================================================================
Enter an integer :13
13, is an odd integer

RUN2
Enter an integer :24
24, is an even integer