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 quick sort in c?
What are qualifiers?
Is there a built-in function in C that can be used for sorting data?
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
What are the data types present in c?
What is data types?
Why c is called object oriented language?
What is the difference between āgā and āgā in C?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
Explain the difference between the local variable and global variable in c?
Explain the term printf() and scanf() used in c language?
What is the correct declaration of main?
What is pragma c?
What is #include stdio h?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"