write a program to find out number of on bits in a number?
Answer Posted / krishna kanth
#include<stdio.h>
main()
{
int setbit=1;
int number=16;//for example
int numBitSet=0;
clrscr();
while(setbit<=number)//important and optimized condition
{
if(number&setbit)
numBitSet++;
setbit=setbit<<1;
}
printf("%d",numBitSet);
getch();
}
| Is This Answer Correct ? | 10 Yes | 3 No |
Post New Answer View All Answers
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What is difference between array and structure in c?
How can you find out how much memory is available?
Why do we need functions in c?
Why double pointer is used in c?
i have a written test for microland please give me test pattern
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
What is the difference between array and linked list in c?
Explain spaghetti programming?
Differentiate between new and malloc(), delete and free() ?
What are the functions to open and close the file in c language?
What is void main () in c?
Do you have any idea about the use of "auto" keyword?
What is a #include preprocessor?
What is a constant and types of constants in c?