C program to check whether a given number is even or odd.
Q:-Write a C program to check whether a given number is even or odd.
If a number is exactly divisible by 2 then its an even number else it is an odd number.
How to check whether a number is even or odd using if else in C program. C Program to input a number from user and check whether the given number is even or odd. Logic to check even and odd number using if…else in C programming.
#include<stdio.h>
#include<conio.h>
void main()
{
int num;
clrscr();
printf("Enter an integer number: ");
scanf("%d",&num);
/*If number is divisible by 2 then number
is EVEN otherwise number is ODD*/
if(num%2==0)
printf("%d is an EVEN number.",num);
else
printf("%d is an ODD number.",num);
getch();
}