Write a Program in C to check whether the given number is odd or even

Write a program to find out whether it is an odd or even number?
Any positive integer is input through the keyboard. The best way to see if a given number is odd or even is to use the modulus operator (%). The modulus operator returns the remainder when dividing two numbers. So if you do a modulus of 6 % 2 you get 0 because 6 divided by 2 doesn’t have a remainder, therefore it’s even. If you do 3 % 2 the remainder will be 1, therefore the number is odd.
// Program to check whether a number is odd or even
void main()
int n;
printf(“Enter any Number “);
if (n%2==0)
printf(“nThe number is even”);
printf(“nTHe number is odd”);
printf(“nnnnnPress any Key to exit…”);

Leave a Reply