# C++ Program to Check Whether Number is Even or Odd

## Program to check whether a number is even or odd

Here we will discuss how to check whether a number is even or odd in C++ programming language.

• A number is even if it is divisible by 2
• To check this we use if else statement along with the % (modulus) operator.
• modulus operator returns remainder when first number is divided by second
• If the condition is true i.e. number is divisible by 2 then the number is even
• Otherwise the number is odd   ## Algorithm:-

1. Input a integer  number
2. check wether the number is divisible by 2
1. if yes, print “Even number”
2. if not, print “Odd number”

### C++ Code:-

```//C++ Program
// number is even or odd
#include<stdio.h>
using namespace std;
int main()
{
cout<<"Enter a number: "; int check; cin>>check;
//checking whether the number is even or odd
if(check % 2 == 0)
{
cout<<check<<" is an even number";
}
else
{
cout<<check<<"is an odd number";
}
return 0;
}```

### Output

```Enter a number: 4
4 is an even number
``` 