write a program to find out number of on bits in a number?

Answer Posted / rajkumar

#include<stdio.h>
void main()
{
int a,count=0;
while(a>0)
{
if(a%2==1)
count++;
a=a>>1;
}
printf("no of on bits =%d ",count);
}

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how does flowchart help in writing a program?

838


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

798


Write a program on swapping (100, 50)

843


how many errors in c explain deply

1807


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

967






Explain what are reserved words?

824


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

1745


Is it possible to have a function as a parameter in another function?

810


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

3711


What is difference between structure and union in c programming?

753


What are the types of i/o functions?

928


What is struct node in c?

790


What is the use of header?

813


What are the similarities between c and c++?

778


What are the complete rules for header file searching?

839