Check whether bitwise OR of N numbers is Even or Odd | C ++ implementation to check whether bitwise OR of n numbers is even or odd ; Function to check if bitwise OR of n numbers is even or odd ; if at least one odd number is found , then the bitwise OR of all numbers will be odd ; Bitwise OR is an odd number ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool check ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) return true ; } return false ; } int main ( ) { int arr [ ] = { 3 , 9 , 12 , 13 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( check ( arr , n ) ) cout << " Odd ▁ Bit - wise ▁ OR " ; else cout << " Even ▁ Bit - wise ▁ OR " ; return 0 ; }