Give a method to count the number of ones in a 32 bit number?
Answer Posted / jayaprakash
#include<stdio.h>
#include<conio.h>
main()
{
int i;
int n;
int count=0;
int j;
int res=0;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
for(j=15;j>=0;j--)
{ i=1;
i=i<<j;
res=i&n;
if(res!=0)
count++;
}
printf("\nNumber of ones is:%d",count);
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is extern keyword in c?
What is omp_num_threads?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
what is a function method?give example?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
Explain threaded binary trees?
Explain what is output redirection?
Can a variable be both static and volatile in c?
How can I get back to the interactive keyboard if stdin is redirected?
What is non linear data structure in c?
Is fortran faster than c?
The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.
can anyone please tell about the nested interrupts?
hi any body pls give me company name interview conduct "c" language only
How do I get an accurate error status return from system on ms-dos?