Check Whether the Number is Even or Odd in C++

0 Suresh Chand March 28, 2021

In this example, We will check whether number is even or odd.

To check whether number is even or odd, We will divide number by 2. If it gives remender 0 then that number is even otherwise that number is odd.

Let’s look an example to make clear concepts

#include<iostream>
using namespace std;

int main()
{
    int num;

    cout << "Enter a Number: ";
    cin >> num;

    if( num % 2 == 0 )
        cout<<"\nIt is an Even Number." << endl;
    else
        cout<<"\nIt is an Odd Number." << endl;

    return 0;
}

The output of above program is

Enter a Number : 10
It is an Even Number

Enter a Number : 11
It is an Odd Number
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by codehelppro.com

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System