Check whether product of ' n ' numbers is even or odd | C ++ implementation to check whether product of ' n ' numbers is even or odd ; function to check whether product of ' n ' numbers is even or odd ; if a single even number is found , then final product will be an even number ; product is an odd number ; Driver program to test above
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isProductEven ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( ( arr [ i ] & 1 ) == 0 ) return true ; return false ; } int main ( ) { int arr [ ] = { 2 , 4 , 3 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isProductEven ( arr , n ) ) cout << " Even " ; else cout << " Odd " ; return 0 ; }