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
How is a pointer variable declared?
Why isn't it being handled properly?
Give me the code of in-order recursive and non-recursive.
What are enums in c?
What are the properties of union in c?
What does p mean in physics?
What is the need of structure in c?
what is the function of pragma directive in c?
What is the best organizational structure?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What is an auto variable in c?
How do you construct an increment statement or decrement statement in C?
What are qualifiers?
Under what circumstances does a name clash occur?
What is the difference between the expression “++a” and “a++”?