c++ program to show that user enter number is even or odd...?
C++ program to show that user enter number is even or odd
Even number: A number which can divided by two and its remainder is equal to zero.
Odd number: A number which can divided by two and its remainder is not equal to zero.
#include <iostream>
using namespace std;
int main()
{
int no,x,y;
while(x!=0)
{
cout<<"Enter a number:"<<"\n";
cin>>no;
if(cin.fail())
{
cout<<"You enter a wrong data";
break;
}
else if (no%2==0)
{
cout<<"This is an even number"<<"\n\n";
}
else
{
cout<<"This is an odd number"<<"\n\n";
}
cout<<"press 0 for exit to programe (OR) for continue to press any key :"<<"\n";
cin>>x;
}
return 0;
}
Comments
Post a Comment