Even and Odd Program in C++
Even and Odd program in C++. In General meaning, even number are those which are divisible by 2 and odd number are those which is not divisible by 2. The same condition applies to programming. In C++ coding we find modulus (%) of any number if the reminder is zero it means it is even number.
Odd Even Program in C++ Code
#include<iostream.h>
#include<conio.h>
int main()
{
int a;
cout<<"Enter any number : ";
cin>>a;
if(a%2==0)
cout<<"This is even number";
else cout<<"This is odd number";
return 0;
}
Output
Enter any number: 10
This is even number
No comments:
Post a Comment