Problem
Write a program in C++ language to find if the given number is odd or even.
Solution
A number is even if it is a positive number and if it is fully divisible by 2.
Here’s a sample code snippet demonstrating how to find out if the number is odd or even in C++.
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter a number";
cin>>a;
if(a%2==0)
{
cout<<"\nThe Number is EVEN Number.\n";
}
else
{
cout<<"\nThe Number is ODD Number.\n";
}
return 0;
}Output

Leave a Reply