Check all the elements in an array are even using library in C++
We are given an array of elements and we have to check the whether each element is even or not.
Input : [2, 4, 6, 8, 9] Output : All the elements are not even Input : [4, 6, 8, 12, 14] Output : Alla the elements are even
Approach: The above problem can be solved using for loop but in C++ we have all_of() algorithm which operates on whole array and save time to write code for loop and checks each element for the specified property.
Note that all_of() also uses loop internally, it just saves our time of writing a loop code.
All are not even elements