Create a function that takes in an array and returns true if all its values are even, and false otherwise.
Not a big deal, your friend says. He writes the following code:
bool checkAllEven(std::vector<int> v) {
return (std::all_of(v.cbegin(), v.cend(), [](int i){ return i % 2 != 0; }))
}Fix the code above so that all tests pass:
checkAllEven([1, 2, 3, 4]) ➞ false
checkAllEven([2, 4, 6]) ➞ true
checkAllEven([5, 6, 8, 10]) ➞ false
checkAllEven([-2, 2, -2, 2]) ➞ trueFor help, check Resources or ask a question in the Comments.