Write c++ program to check whether agiven number is even or odd
#include <iostream>
using namespace std;
int main() {
int n;
cout<<"Enter integer N: ";
cin>>n;
if(!cin){
cout<<"Invalid input."<<endl;
cin.clear();
exit(1);
}
if(n%2==0)
cout<<"Even";
else
cout<<"Odd";
cout<<endl;
return 0;
}
Comments
Leave a comment