Last active
April 26, 2016 21:37
-
-
Save rabiulcste/413605f0fbd9205f9243f7e719bf6bee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int countSetBits(unsigned int n) | |
{ | |
unsigned int count = 0; | |
while(n) | |
{ | |
count += n & 1; // ভাগশেষ ০ নাকি ১ । যদি ১ হয় তাহলে কাউন্টের মান বেড়ে যাবে । | |
n >>= 1; // n কে দুই দিয়ে ভাগ করা হচ্ছে । | |
} | |
return count; | |
} | |
int main() | |
{ | |
int i = 9; | |
printf("%d", countSetBits(i)); | |
getchar(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment