I understand the following program, not that well but at least i know how it works. But i really can't figure out what it does. Pls give some hints.
int mystery( unsigned );
printf( "Enter an integer: " );
scanf( "%u", &x );
printf( "\nThe result is %d\n", mystery( x ) );
int mystery( unsigned bits )
unsigned i, mask = 1 << 31, total = 0;
for ( i = 1; i <= 32; i++, bits <<= 1 )
if ( ( bits & mask ) == mask )
return !( total % 2 ) ? 1 : 0;
It counts the occurences of 1's in the binary equývalent of an unsigned integer and returns 1 if the total number of 1's is odd, 0 for even.