write a program to find out number of on bits in a number?
Answer Posted / naveen
//plz let me know whether it is correct or not...bcoz am just beginner
#include<stdio.h>
void main()
{
int j=0,i=0xFFFFE,temp=1;
int count=0;
while(j<=(sizeof(int)*8-1))
{
if(i&temp)
count++;
temp=temp<<1;
j++;
}
printf("%d",count);
}
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is malloc calloc and realloc in c?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
Is there any possibility to create customized header file with c programming language?
What are predefined functions in c?
Explain what are multibyte characters?
can anyone please tell about the nested interrupts?
Write a program to check whether a number is prime or not using c?
How does struct work in c?
Suggesting that there can be 62 seconds in a minute?
to find the closest pair
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
How can I send mail from within a c program?
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.
What does *p++ do? What does it point to?
What is the purpose of main( ) in c language?