write a program to find out number of on bits in a number?
Answer Posted / anu
#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=1;
while(n!=0)
{
rem=n%2;
n=n/2;
cnt++;
}
printf("number of bits of the number is = %d",cnt);
getch();
}
Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
What does a function declared as pascal do differently?
How many bytes is a struct in c?
What is the heap?
How do you do dynamic memory allocation in C applications?
What is strcmp in c?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
Describe how arrays can be passed to a user defined function
What is the Purpose of 'extern' keyword in a function declaration?
What are control structures? What are the different types?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
Is it cc or c in a letter?
What is character set?
How can I split up a string into whitespace-separated fields?
What is switch in c?
Is array a primitive data type in c?