write a program to find out number of on bits in a number?
Answer Posted / rajkumar
#include<stdio.h>
void main()
{
int a,count=0;
while(a>0)
{
if(a%2==1)
count++;
a=a>>1;
}
printf("no of on bits =%d ",count);
}
| Is This Answer Correct ? | 15 Yes | 1 No |
Post New Answer View All Answers
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
What is the use of printf() and scanf() functions?
What is the difference between near, far and huge pointers?
Explain how can you restore a redirected standard stream?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Explain what is page thrashing?
Can we use any name in place of argv and argc as command line arguments?
What do you mean by scope of a variable in c?
pierrot's divisor program using c or c++ code
Is return a keyword in c?
Whats s or c mean?
Explain the use of 'auto' keyword
What is the difference between the = symbol and == symbol?
Why do we write return 0 in c?