C program to check number is even or odd.

Posted by Mangesh on March 14, 2018

/* Program to check whether the number is even or odd number. */

Description :

Even Number :
Any integer that can be divided exactly by 2 is an even number. The last digit is 0, 2, 4, 6 or 8.
Example 2, 56, 100, etc

Odd Number :
Any integer that cannot be divided exactly by 2 is an odd number. The last digit is 1, 3, 5, 7 or 9
Example 1, 65, 987, etc

Logic :

We need to describe the concept of even number and odd number in the mathematical form so that we can use it in our program.
Even number are the number divisible by 2, so we can represent even as any number which when divided by 2 gives remainder as 0.
and odd number are simply the number which are not even.

Program :

#include<stdio.h>
#include<conio.h>
void main()
{
   int number;
   printf("Enter the number: ");
   scanf("%d",&number);
   if(number % 2==0)
      printf("%d is a even number.",number);
   else
     printf("%d is a odd number.",number);
   getch();
}

Output :

c program for even odd number` program run in turbo c 3.2

Skills Required :

If-Else statements

Written with from Mangesh.

Related Post
1 C program to check number is even or odd.
2 C program to swap to number.
3 C program to check whether the year is leap year or not.
4 C program to check whether enter alphabet is vowel or not.
Latest Post
1 C program to implement Queue using linked list.
2 C program for binary search tree (BST).
3 C program to search an element in linked list.
4 C program for postorder traversal in binary tree.
5 C program for preorder traversal in binary tree.