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
Is there anything like an ifdef for typedefs?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
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'); }
What is #include called?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
What Is The Difference Between Null And Void Pointer?
What is scanf () in c?
What is void main () in c?
What are reserved words with a programming language?
What are the different types of control structures?
When should you use a type cast?
What does c in a circle mean?
explain what are actual arguments?
Explain what is a pragma?
What is d'n in c?