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
State two uses of pointers in C?
Explain what does it mean when a pointer is used in an if statement?
What are data types in c language?
What is the difference between functions abs() and fabs()?
Explain what is the difference between a free-standing and a hosted environment?
write a program to rearrange the array such way that all even elements should come first and next come odd
What is calloc malloc realloc in c?
How many parameters should a function have?
What is a lookup table in c?
Explain b+ tree?
how to build a exercise findig min number of e heap with list imlemented?
Can I initialize unions?
I have seen function declarations that look like this
How can you avoid including a header more than once?
Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.