how do u find out the number of 1's in the binary
representation of a decimal number without converting it
into binary(i mean without dividing by 2 and finding out
the remainder)? three lines of c code s there it
seems...can anyone help
Answer Posted / barun
int x =0x1;
static count;
while(no ! =0)
{
if((no >>1 & x) ==1)
count+=1;
}
printf("%d",count);
Is This Answer Correct ? | 7 Yes | 2 No |
Post New Answer View All Answers
What is difference between main and void main?
What does it mean when the linker says that _end is undefined?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
What is null pointer constant?
When is a void pointer used?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
Explain what does it mean when a pointer is used in an if statement?
Difference between exit() and _exit() function?
What is difference between far and near pointers?
What is a pointer in c?
how to capitalise first letter of each word in a given string?
What is modifier & how many types of modifiers available in c?
Explain 'bus error'?
Is it better to use a macro or a function?
What are the key features in c programming language?