write a program to find out number of on bits in a number?
Answer Posted / venkat reddy
main()
{
int n,counter;
printf("enter a number");
scanf("%d",&n);// let n=5
while(n>0)
{
counter++;
n=n&(n-1);
}
printf("%d",counter);
getch();
}
Is This Answer Correct ? | 11 Yes | 2 No |
Post New Answer View All Answers
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
How are structure passing and returning implemented?
What does main () mean in c?
What does the c in ctime mean?
What is c language used for?
Explain what is the difference between a free-standing and a hosted environment?
What is the method to save data in stack data structure type?
Why is c used in embedded systems?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
What is the size of structure in c?
Why is c called a mid-level programming language?
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
is it possible to create your own header files?
What is a structural principle?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list