ITGUY31 - Editorial

Problem: Contest Page | CodeChef

DIFFICULTY:

EASY.

PROBLEM:

Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challenges the chef to print the total number of 0’s in the binary representation of N(natural number).

Program:

#include<bits/stdc++.h>
using namespace std;
int main()
 {
	//code
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
   	int t,n,sum;
   	cin>>t;
	for(int i=1;i<=t;i++)
	{
	    sum=0;
	    cin>>n;
	    while(n>0){
	    	if(n%2==0)sum++;
	    	n=n/2;
	    }
	    cout<<sum<<"\n";
	}
}