Pergunta de entrevista da empresa Fortinet

How would you write a program to find out how many set bits are in a number?