DESCRIPTION: This program finds the total number of ones in a given binary number.
PROGRAM:
#include<stdio.h>
main()
{
int count=0,num,rem;
printf("enter the number\n");
scanf("%d",&num);
while(num!=0)
{
rem=num%10;
if(rem==1)
count++;
num=num/10;
}
printf("number of ones=%d", count);
}
OUTPUT WINDOW: