Intel Corporation interview question

write a function to see how many bits are set in an integer.

Interview Answers

Anonymous

Jul 1, 2012

while(n>0){ (n&(n-1)) count++; }

Anonymous

Jul 12, 2011

use bit wise operators. && and shift operators.