write a program to find out number of on bits in a number?
Answer Posted / vivek
int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number
while(setbit>0)
{
if(number&setbit) //bit wise and
numBitSet++;
setbit=setbit<<1;
}
| Is This Answer Correct ? | 23 Yes | 12 No |
Post New Answer View All Answers
Explain enumerated types.
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.
How can type-insensitive macros be created?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What is typedef?
What is the meaning of 2d in c?
What are pointers in C? Give an example where to illustrate their significance.
What is the sizeof () operator?
What is the right type to use for boolean values in c? Is there a standard type?
How many main () function we can have in a project?
Can an array be an Ivalue?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
What are linker error?
What is the difference between strcpy() and memcpy() function in c programming?