6.9: Returning a Boolean Value
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 .
bool isEven(int x){ if (x%2 == 0){ return true; } else { return false; } }
Write the definition of a function isPositive, that 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 .
bool isPositive(int x){ if (x > 0) { return true; } else { return false; } }
Write the definition of a function isSenior, that receives an integer parameter and returns true if the parameter 's value is greater or equal to 65, and false otherwise. So, if the parameter 's value is 7 or 64 or 12 the function returns false . But if the parameter 's value is 69 or 83 or 65 the function returns true .
bool isSenior(int x ){ if (x >=65){ return true; } else{ return false; } }