#include
using namespace std;
int count_set_nits (int n)
{ int count;
while( n > 0)
{
n = n&(n-1);
count++;
}
return count;
}
int main() {
int t;
cin>>t;
while(t>0)
{
int n;
cin>>n;
cout<<count_set_nits<<endl;
t–;
}
return 0;
}
Check my code there is some problem
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.