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 are the two types of functions in c?
When would you use a pointer to a function?
Do you know the use of 'auto' keyword?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
What is the difference between array and linked list in c?
What is the difference between mpi and openmp?
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
What is pass by reference in functions?
Explain the difference between structs and unions in c?
what do the 'c' and 'v' in argc and argv stand for?
Difference between MAC vs. IP Addressing
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
What is c language & why it is used?
Can you please explain the difference between exit() and _exit() function?
What is the purpose of clrscr () printf () and getch ()?