1) Write the definition of a function isEven, which 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 .
2) Write the definition of a function isPositive, which receives an integer parameter and returns true if the parameter is positive, and false otherwise.
So if the parameter 's value is 7 or 803 or 141 the function returns true . But if the parameter 's value is -22 or -57, or 0, the function returns false .
My Code:
1 2 3 4 5 6 7 8 9
bool isPositive ( int x ) {
if ( x > 0 )
{
returntrue;
}
else {
returnfalse ;
}
}
Read the problem definition before posting. In the problem definition, 0 is supposed to return false. The OP's code is correct as is and yours is wrong.
This is, by the way, the correct answer. 0 is NOT a positive number. Nor is it a negative number. It should never be considered or implied as a positive number.