1. Write a function called isEven() that uses the remainder operator(%) to determine whether an integer is even or not.
#include <iostream>
using namespace std;
bool isEven(int a){
return a%2 == 0? true : false;
}
int main()
{
int a;
cout<<"Input an integer...\n";
cin>>a;
string str = isEven(a) ? " is even.": " is odd.";
cout<<a<<str;
return 0;
}
Comments