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
Compare interpreters and compilers.
What is typedf?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
What is pointers in c with example?
If errno contains a nonzero number, is there an error?
which is an algorithm for sorting in a growing Lexicographic order
regarding pointers concept
What is a sequential access file?
Differentiate fundamental data types and derived data types in C.
What are different types of operators?
Differentiate between full, complete & perfect binary trees.
Explain what is the best way to comment out a section of code that contains comments?
What is difference between function overloading and operator overloading?
What are comments and how do you insert it in a C program?
What is .obj file in c?