write a program to find out number of on bits in a number?
Answer Posted / ajay vikram
void main()
{
int number,a=0,b,count=0;
printf("Enter the number : ");
scanf("%d",&number);
b = (number/2);
while(b)
{
if((number>>a)& 1)
{
count++;
}
a++;
b--;
}
printf("Number of ON Bits in the number : %d\n",count);
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Why c is called procedure oriented language?
What does %c do in c?
What is wrong with this statement? Myname = 'robin';
When should I declare a function?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
What is data types?
Difference between MAC vs. IP Addressing
What is c language & why it is used?
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
What is the newline escape sequence?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
What is wrong in this statement?
what is the different bitween abap and abap-hr?
find out largest elemant of diagonalmatrix
Explain the use of bit fieild.