#include<stdio.h>
#include<math.h>
int main()
{
int num,i,count0=0,count1=0;
printf("enter number \n");
scanf("%d",&num);
for(i=0;i<32;i++)
{
if(num &((pow(2,31))>>i))
count1++;
else
count0++;
}
printf(" the no. of 0's and 1's in the given number are %d %d",count0,count1);
}
mangalasadu 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.