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 does this code crash?
How do c compilers work?
Is c# a good language?
How do you initialize pointer variables?
What are the advantages and disadvantages of c language?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
Whats s or c mean?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
What is pointers in c with example?
What is main () in c?
main() { printf("hello"); fork(); }
Which is better between malloc and calloc?
Is void a keyword in c?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions