document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int getCountOfSetBits (int n)
  6. {
  7.     unsigned int count = 0;
  8.     while (n)
  9.     {
  10.         count += n & 1;
  11.         n >>= 1;
  12.     }
  13.     return count;
  14. }
  15.  
  16. int main (void)
  17. {
  18.     int n;
  19.     cin >> n;
  20.     cout << "No. of set bits: " << getCountOfSetBits (n) << endl;
  21.     return 0;
  22. }
');