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 is the meaning of typedef struct in c?
What is putchar() function?
Write a simple code fragment that will check if a number is positive or negative.
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
Can 'this' pointer by used in the constructor?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What is calloc()?
How many levels of pointers can you have?
Differentiate fundamental data types and derived data types in C.
Tell us something about keyword 'auto'.
Where local variables are stored in c?
What is #ifdef ? What is its application?
What are loops c?
What is %s and %d in c?
What is the -> in c?