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 C language ?
How can I copy just a portion of a string?
Is c compiled or interpreted?
What is the default value of local and global variables in c?
What is the role of this pointer?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
What are the types of variables in c?
What is difference between far and near pointers?
When should I declare a function?
Give basis knowledge of web designing ...
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
What is pass by reference in c?
What is c preprocessor mean?
Why c is a procedural language?
How do we make a global variable accessible across files? Explain the extern keyword?