Tutorials, Free Online Tutorials,It Challengers provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, core java, sql, php, c language etc. for beginners and professionals.

Breaking

14. Counting set bits in a number.


14.Counting set bits in a number.

int CoutSetBits(int Num)
for(int count=0; Num; Num >>= 1)
{
 if (Num & 1) 
count++;
}
return count;
 }

int CoutSetBits(int Num)
{
 for(int count =0; Num; count++)
{
  Num &= Num -1;
 }

No comments:

Post a Comment