Count no of bits

https://hack.codingblocks.com/app/contests/1483/104/problem

@varunkmr038
How can I help you buddy
What is your query ??

1 Like

#include
using namespace std;
int main() {
int n,t;
unsigned int count=0;
cin>>t;
while(t>0){
cin>>n;

while( n > 0)
    {
    n = n&(n-1);
       count++;
    }
cout<<count<<endl;
t--;
}
return 0;

}

this code is not passing test case in this problem

@varunkmr038
Put line unsigned int count=0;
After cin>>n;

Please close the doubt

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like