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.

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<iostream.h>
	#include<conio.h>
	
	//EVEN & ODD PROGRAM
	void main()
	{
		clrscr();
		int n;
		cout<<"ENTER A NUMBER:- ";
		cin>>n;
		if(n%2 == 0)
		{
			cout<<"ENTER NUMBER IS ODD";
		}
		else
		{
			cout<<"ENTER NUMBER IS ODD";
		}
		getch();
	}

Output:


	ENTER A NUMBER:- 6
	ENTER NUMBER IS EVEN.

Post Your Comment