Give a method to count the number of ones in a 32 bit number?
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned i;
int j=0,count=0;;
printf("Enter the number :");
scanf("%ld",&i);
while(j<=31)
{
if(!(((i>>j)&1)^1))
count++;
j++;
}
printf("\nnumber of 1's in ur number is : %d",count);
getch();
}
thank u
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What does 1f stand for?
What is ambagious result in C? explain with an example.
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
How is null defined in c?
What is function prototype in c language?
Why does not c have an exponentiation operator?
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university
What does s c mean on snapchat?
What is the use of pointers in C?
What is the use of in c?
Is there anything like an ifdef for typedefs?
Why we not create function inside function.
What is identifier in c?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?