Count set bits of X
while ( X != 0 ) { X = ( X - 1 ) & X ; count ++ ; } if ( count % 2 == 0 ) { cout << even_count << " ▁ " << odd_count << " STRNEWLINE " ; } else { cout << odd_count << " ▁ " << even_count << " STRNEWLINE " ; } } }