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 / ravi saini
unsigned int count=0,no;
/*
Enter no Here................
*/
while(no ! =0)
{
if((no & 0x01) ==1)
count++;
no=no >>1
}
printf("%d",count);
| Is This Answer Correct ? | 9 Yes | 3 No |
Post New Answer View All Answers
What should malloc(0) do?
What does main () mean in c?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
The __________ attribute is used to announce variables based on definitions of columns in a table?
What is sizeof array in c?
What is unary operator?
what are the different storage classes in c?
What is d scanf?
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
How can I make sure that my program is the only one accessing a file?
What does sizeof return c?
how can I convert a string to a number?
What is register variable in c language?
What does double pointer mean in c?