Answer to Question #15481 in C++ for Aadya
write a program to find whether a given number is even or odd.
1
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!
Learn more about our help with Assignments:
C++
Comments
Leave a comment