In this program we make use of the logic that an even number is always divisible by 2.Which means on diving a number by 2 the remainder must be zero.
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("Enter a number");
scanf("%d",&a);
if(a%2==0) // comparing the remainder with 0
printf("EVEN NUMBER");
else
printf("ODD NUMBER");
getch();

0 comments:
Post a Comment