C Program to Check Whether a Given Positive Integer is Even or Odd
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int num;
clrscr();
printf("Enter positive integer: ");
scanf("%d", &num);
if(num%2==0)
{
printf("%d is even.", num);
}
else
{
printf("%d is odd", num);
}
getch();
}
Output of the above program :
Run 1: -------------- Enter positive integer: 67 ↲ 67 is odd Run 2: -------------- Enter positive integer: 86 ↲ 86 is even Note: ↲ indicates ENTER is pressed.