Any number that can be perfectly divisible by 2 is known as an even number. While the one which does not divides by 2 perfectly is known as an odd number.

Perfectly divisible means, that the number on division produces 0 as remainder.


  1. Input a number
  2. Check if its remainder is 0 on dividing with 2 (using %2)
  3. Using if-else find number is even or odd.

The below code checks if the integer entered by the user is even or odd:

#include <iostream>
using namespace std;
int main()
    int num;
    //Input the number
    cout<<"Enter an integer: ";
    if (num % 2 == 0)//check its divisibility with 2
         cout<< num << " is even.";
        cout<< num <<" is odd.";
    return 0;


Enter an Integer:234

234 is even.

Report Error/ Suggestion

Related Posts:

CopyRight © 2020

CopyRight © 2020