I'm assuming this homework so you're not allowed to do it in the sensible fashion, yes?
You'll want to loop through looking for whether or not binary "digits" are set. I'd do this by using the binary '&' operator (not the '&&' operator!), and progressively shifting what I'm comparing it to. Do you understand what the & and >> or << operators do?