Answer to Question #15481 in C++ for Aadya

Question #15481
write a program to find whether a given number is even or odd.
1
Expert's answer
2012-09-28T09:00:14-0400
#include<iostream.h>

bool even(int i){
if (i%2==0) return true;
else return false;
}

int a;

void main(){
cout<<"Enter an integer: ";
cin>>a;
if (even(a)) cout<<"Entered integer is even.\n";
else cout<<"Entered integer is odd.\n";
}

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