# Check whether given number is even or odd

“* Check whether given number is even or odd*” is a very basic programming exercise problem for beginners. Here, we are given a number, entered by user and our task is to write a program to check whether a given number is even or odd.

**Even number**: A number which is divisible by 2.

**Odd number**: A number which is not divisible by 2.

**Example:**

Number = 4INPUT:4 is even numberOUTPUT:Number = 7INPUT:7 is odd number.OUTPUT:

We can simply check the divisibility condition to check whether a number is even or odd.

**C++ Program to check whether a number is even or odd** **is as follows:**

#include<bits/stdc++.h> using namespace std; int main() { int num; //Scan the number cout<<"Enter the number:"; cin>>num; // Even : Divisible by 2 if(num % 2 == 0) { cout<<num<<" is even number"; } // Odd : Not Divisible by 2 else if(num % 2 != 0) { cout<<num<<" is odd number"; } }

OUTPUT:Enter the number: 4 4 is even number

**Related Posts:**

**Program to check whether entered number is prime number or not.****Program to check whether entered number is palindrome or not.****Program to check whether entered number is Armstrong Number or Not.****Program to convert binary number to octal number.****Program to convert binary number to decimal number.****Program to convert binary number to hexadecimal number.****Program to convert octal number to binary number.****Program to convert octal number to decimal number.****Program to convert octal number to hexadecimal number.****Program to convert decimal number to binary number.****Program to convert decimal number to octal number.****Program to convert decimal number to hexadecimal number.****Program to convert hexadecimal number to binary number.****Program to convert hexadecimal number to octal number.****Program to convert hexadecimal number to decimal number.****Program to check Leap Year.****Program to find largest amongst three numbers.****Program to find factorial of a number.****Program to find GCD of two numbers.****Program to find LCM of two numbers.**