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
Tell me is null always defined as 0(zero)?
What is c programing language?
How can I read in an object file and jump to locations in it?
What is the c language function prototype?
Why is c known as a mother language?
Difference between pass by reference and pass by value?
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Explain high-order bytes.
Which built-in library function can be used to match a patter from the string?
What is the difference between array and pointer in c?
What is the difference between variable declaration and variable definition in c?
What are the two forms of #include directive?
What are the ways to a null pointer can use in c programming language?
How many bytes are occupied by near, far and huge pointers (dos)?