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 % operator.
  • If the condition is true i.e. number is divisible by 2 then the number is even
  • Otherwise the number is odd


  • User gives an input.
  • Input is stored in an int type variable say prep.
  • prep is then checked using the if else statement with the condition


  • If the above mentioned condition is true then the number is an even number.
  • Otherwise the number is an odd number.
Program to check A number is even or odd

C++ Code:

//C++ Program
// number is even or odd
using namespace std;
int main()
    cout<<"Enter a number: ";
    int check;
    //checking whether the number is even or odd
    if(check % 2 == 0)
        cout<<check<<" is an even number";
        cout<<check<<" is an odd number";
    return 0;


Enter a number: 97
97 is an odd number

Please Login/Signup to comment