You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
458 B
C

/*
* C Program to Count the Number of Bits set to One using
* Bitwise Operations
*/
#include <stdio.h>
int main()
{
unsigned int number;
int count = 0;
printf("Enter the unsigned integer:\n");
scanf("%d", &number);
while (number != 0)
{
if ((number & 1) == 1)
count++;
number = number >> 1;
}
printf("number of one's are :\n%d\n", count);
return 0;
}