write a program to find out number of on bits in a number?
Answer Posted / arijit
#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=0;
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 | 0 No |
Post New Answer View All Answers
What is pass by reference in c?
Do variables need to be initialized?
Compare and contrast compilers from interpreters.
Write the test cases for checking a variable having value in range -10.0 to +10.0?
What is a shell structure examples?
What is define c?
What is operator precedence?
How do you generate random numbers in C?
Explain how can you check to see whether a symbol is defined?
What is the use of getchar functions?
What are the different properties of variable number of arguments?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
what is use of malloc and calloc?
How many types of functions are there in c?
What library is sizeof in c?