Count pairs with Bitwise XOR as EVEN number | Function to count number of even pairs ; variable for counting even pairs ; find all pairs ; find XOR operation check even or even ; return number of even pair ; Driver Code ; calling function findevenPair and print number of even pair
function findevenPair ( A , N ) { let i , j ; let evenPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] ^ A [ j ] ) % 2 == 0 ) evenPair ++ ; } } return evenPair ; } let A = [ 5 , 4 , 7 , 2 , 1 ] ; let N = A . length ; document . write ( findevenPair ( A , N ) ) ;