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.

1
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.

LANGUAGE: C++

CHALLENGE:

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.

SOLUTION:


bool isEven(int x){
    if (x % 2 == 0) {
        return true;
    } else {
                return false;
        }
}

One comment

Add comment