Even or Odd Number - C++ Program

Q. Write a C++ program to check whether the input number is an even or an odd number.

Answer:

Following program shows that whether the number entered by user is an Even number or an Odd number.

#include<iostream>
using namespace std;
int main()
{
        int num;
        cout<<"\n Enter Number : ";
        cin>>num;
        if(num%2==0)
        {
                cout<<"\n Even Number";
        }
        else
        {
                cout<<"\n Odd Number";
        }
        return 0;
}


Output:

even odd