Answer to Question #337682 in C++ for Dile

Question #337682

Write c++ program to check whether agiven number is even or odd

1
Expert's answer
2022-05-05T09:33:17-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS