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
Explain is it valid to address one element beyond the end of an array?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
What is the importance of c in your views?
What are the general description for loop statement and available loop types in c?
Why is event driven programming or procedural programming, better within specific scenario?
The file stdio.h, what does it contain?
Write the syntax and purpose of a switch statement in C.
What is the significance of scope resolution operator?
What is the newline escape sequence?
Where define directive used?
Explain how can a program be made to print the name of a source file where an error occurs?
What is data type long in c?
What is hashing in c?
Explain what is wrong with this statement? Myname = ?robin?;
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above