Count pairs with Bitwise AND as ODD number | C ++ program to count pairs with Odd AND ; Count total odd numbers in ; return count of even pair ; Driver main ; calling function findOddPair and print number of odd pair
#include <iostream> NEW_LINE using namespace std ; int findOddPair ( int A [ ] , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( ( A [ i ] % 2 == 1 ) ) count ++ ; return count * ( count - 1 ) / 2 ; } int main ( ) { int a [ ] = { 5 , 1 , 3 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findOddPair ( a , n ) << endl ; return 0 ; }