This program will count total number of 1's in an integer number. Here we are counting total number of 1's in an integer number using a User Define Function.
/*C program to count number of 1's in a number */
int count1s(unsigned int num)
unsigned char i;
unsigned char totalBits=sizeof(num)*8;
if( num & (1<< i) )
unsigned int data=0x58;
printf("\nTotal number of 1's are : %d\n",count1s(data));
Total number of 1's are : 3
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.