write a program to find out number of on bits in a number?
Answer Posted / madhu
#include <stdio.h>
main()
{
int number;
int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number
printf("enter the number");
scanf("%d", &number);
while(setbit>0)
{
if(number&setbit) //bit wise and
numBitSet++;
setbit=setbit<<1;
}
printf("%d",numBitSet);
}
full program of the first ans...
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.
In C programming, what command or code can be used to determine if a number of odd or even?
What is page thrashing?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
What is a c token and types of c tokens?
Are the variables argc and argv are local to main?
What is meant by high-order and low-order bytes?
What are local variables c?
Give basis knowledge of web designing ...
How do you determine a file’s attributes?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
What is the use of #include in c?
Can variables be declared anywhere in c?
Explain what is the benefit of using an enum rather than a #define constant?
What is a volatile keyword in c?