The problem is to produce a function
which examines the bits in x, returning a count of
the number of 1-bits. There are various ways of doing
(1) a sane way. Shift the word x right 16 times (you are
on UNIX) and check the rightmost bit each time, counting
the number of times it is '1'.
(2) a machine-independent (sort of) way. The logical
bitwise AND of x and x-1 contains one fewer one bit than x itself.
Loop anding x and x-1 until you get zero.
Program either algorithm. Compile and test it. Leave it on
a file bitct.c and type "ready".
if (bitct(x) != goodct(x)) return(1);
if (bitct(x) != goodct(x)) return(1);
if (bitct(x) != goodct(x)) return(1);
if (bitct(x) != goodct(x)) return(1);
if (bitct(x) != goodct(x)) return(1);
/* a possible solution */
/* by the way, if you really care about
this problem a table lookup by whole bytes