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 main function in c?
What is the difference between printf and scanf )?
How can I direct output to the printer?
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
Do array subscripts always start with zero?
What is the difference between fread and fwrite function?
How do we print only part of a string in c?
Why #include is used in c language?
How will you delete a node in DLL?
i got 75% in all semester am i eligible for your company
how to capitalise first letter of each word in a given string?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Tell us two differences between new () and malloc ()?
Explain how to reverse singly link list.
If errno contains a nonzero number, is there an error?