Even Odd Number Program in C

In this section you will learn how to find whether a number is even or odd in c. We will use if else condition and small mathematic operation to check the even or odd number and we will show the result on output screen. In this program we are taking the input from user.

Even and Odd Number Program

Let’s suppose a user will input a number as a '6' and then we will perform small mathematic operation on it. With the help if else condition we will check whether a number is even or odd.

Example of even number:

2, 4, 6, 8, 10, 12, etc..

Example of odd number:

1, 3, 5, 7, 8, 9, 11, etc.

How program will work?

Program of even odd number in C


	#include<stdio.h>
	#include<conio.h>
	
	//EVEN & ODD PROGRAM
	void main()
	{
		int n;
		clrscr();

		printf("ENTER A NUMBER:- ");
		scanf("%d",&n);
		
		if(n%2==0)
		{
			printf("ENTER NUMBER IS EVEN.");
		}	
		else
		{
			printf("ENTER NUMBER IS ODD.");
		}

		getch();		
	}

Output:


	ENTER A NUMBER:- 6
	ENTER NUMBER IS EVEN.

Post Your Comment