write a program to find out number of on bits in a number?
Answer Posted / vaishu and hema
main()
{
int n,count=0,rem;
scanf("%d",&n);
while(n>0)
{
rem=n%2;
if(rem==1)
count++;
n=n/2;
}
printf("The number of on bits in the number is %d",count);
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
Why is sprintf unsafe?
What is the difference between mpi and openmp?
Can we add pointers together?
What is realloc in c?
Explain data types & how many data types supported by c?
What is time null in c?
What’s a signal? Explain what do I use signals for?
What is #define in c?
What is meant by type specifiers?
Why are all header files not declared in every c program?
Explain the advantages of using macro in c language?
Is there a way to switch on strings?
write a program to print largest number of each row of a 2D array
Find MAXIMUM of three distinct integers using a single C statement
write a program to find the given number is prime or not