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 / srsabariselvan
int main()
{
int n,i=0;
scanf("%d",&n);
while(n!=0)
{
if(n&01)
i++;
n>>=1;
}
printf("%d",i);
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
What is the use of getch ()?
Where are local variables stored in c?
How will you find a duplicate number in a array without negating the nos ?
What is double pointer?
Who developed c language?
What is 2 d array in c?
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
Write a program of advanced Fibonacci series.
Why c is called free form language?
how to find binary of number?
What is the general form of #line preprocessor?
What is the difference between new and malloc functions?
What are high level languages like C and FORTRAN also known as?
How reliable are floating-point comparisons?
Can a local variable be volatile in c?