DIR Return Create A Forum - Home
---------------------------------------------------------
ifaq
HTML https://ifaq.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Simple logic/concept based questions
*****************************************************
#Post#: 2--------------------------------------------------
Count the number of set bits in an integer
By: avinash.srin Date: August 25, 2011, 9:06 am
---------------------------------------------------------
Write a function that takes an integer as input and returns the
number of set bits in it.
For example, if the input is 5, its binary representation is 101
and the number of set bits (bit 1) is 2. So the function returns
2. For 7, it should return 3 and for 2048, it should return 1
and so on.
*****************************************************