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


Please Help Members By Posting Answers For Below Questions

Which node is more powerful and can handle local information processing or graphics processing?

844


What is the condition that is applied with ?: Operator?

671


What is the meaning of ?

638


What does return 1 means in c?

593


Is a pointer a kind of array?

604






What is an expression?

668


What is scanf () in c?

672


what are the facialities provided by you after the selection of the student.

1666


Write a program to print numbers from 1 to 100 without using loop in c?

654


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1482


What is the right type to use for boolean values in c?

596


What do you know about the use of bit field?

620


What is fflush() function?

653


What are the differences between new and malloc in C?

618


In a byte, what is the maximum decimal number that you can accommodate?

636