write a program to find out number of on bits in a number?
Answer Posted / ram
#include<stdio.h>
void main()
{
int a,count=0;
printf("enter a");
scanf("%d",&a);
while(a>0)
{
if(a%2==1)
count++;
a=a>>1;
}
printf("no of on bits =%d ",count);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are structure members?
When the macros gets expanded?
What is #define used for in c?
In a switch statement, what will happen if a break statement is omitted?
Explain logical errors? Compare with syntax errors.
What is the explanation for prototype function in c?
What is meant by gets in c?
How can you return multiple values from a function?
What is the newline escape sequence?
Why is c faster?
Is it valid to address one element beyond the end of an array?
an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational
What is #line?
Can a file other than a .h file be included with #include?
How are strings stored in c?