Write a C++ program to find out whether it is an odd number or even number.

Program Code:

#include<iostream>
using namespace std;
int main()
{
int x;
cout<<"Enter your number to be checked for even or add : ";
cin>>x;
if(x%2 == 0) // condition for checking even or odd.
{
cout<<"The entered number is even : ";
cout<<x;
}
else
{
cout<<"The entered number is odd :";
cout<<x;
}

return 0;
}

The program output is tested on www.jdoodle.com

Output:
Enter your number to be checked for even or add : 8
The entered number is even : 8

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: