my code is not running
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int ans=0;
while(n>0){
if((n&1)==1){
ans++;
}
n = n>>1;
}
cout<<ans<<endl;
}
return 0;
}
my code is not running
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int ans=0;
while(n>0){
if((n&1)==1){
ans++;
}
n = n>>1;
}
cout<<ans<<endl;
}
return 0;
}
hey, ur code is working fine and passing all test cases… try refreshing the page
#include<iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int ans=0;
while(n>0){
if((n&1)==1){
ans++;
}
n = n>>1;
}
cout<<ans<<endl;
}
return 0;
}
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.