write a program to find out number of on bits in a number?
Answer Posted / madhu
#include <stdio.h>
main()
{
int number;
int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number
printf("enter the number");
scanf("%d", &number);
while(setbit>0)
{
if(number&setbit) //bit wise and
numBitSet++;
setbit=setbit<<1;
}
printf("%d",numBitSet);
}
full program of the first ans...
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What should malloc() do?
how is the examination pattern?
Is Exception handling possible in c language?
On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area
Can we declare variables anywhere in c?
Write a program of prime number using recursion.
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
Differentiate between static and dynamic modeling.
What is a pointer value and address in c?
Explain low-order bytes.
What is the difference between array_name and &array_name?
string reverse using recursion
Can a variable be both static and volatile in c?
What is a pointer on a pointer in c programming language?
What are different storage class specifiers in c?