write a program to find out number of on bits in a number?
Answer Posted / arijit
#include<stdio.h>
#include<conio.h>
void main()
{
int n,cnt,rem
scanf("%d",&n);
cnt=0;
while(n!=0)
{
rem=n%2;
n=n/2;
cnt++;
}
printf("number of bits of the number is = %d",cnt);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the types of macro formats?
Write a program to find factorial of a number using recursive function.
What does volatile do?
List a few unconditional control statement in c.
How do I use strcmp?
explain what is fifo?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
in iso what are the common technological language?
How can I read a binary data file properly?
Describe static function with its usage?
In which layer of the network datastructure format change is done
Explain the difference between exit() and _exit() function?
In C programming, what command or code can be used to determine if a number of odd or even?
please give me some tips for the placement in the TCS.
Add Two Numbers Without Using the Addition Operator