193k views
5 votes
Write the definition of a function isEven, that receives an integer parameter and returns true if the parameter's value is even, and false otherwise. So, if the parameter's value is 7 or 93 or 11 the function returns false. But if the parameter's value is 44 or 126 or 7778 the function returns true.

User Thilanka
by
5.2k points

1 Answer

2 votes

Answer:

C++

//////////////////////////////////////////////////////////////////////////////////

#include <iostream>

using namespace std;

/////////////////////////////////////////////////////////

bool isEven(int n) {

if (n%2 == 0)

return true;

else

return false;

}

/////////////////////////////////////////////////////////

int main() {

if (isEven(100) == 1)

cout<<"True"<<endl;

else

cout<<"False"<<endl;

if (isEven(61) == 1)

cout<<"True"<<endl;

else

cout<<"False"<<endl;

return 0;

}

User Christopher Lee
by
4.8k points