write a program to find out number of on bits in a number?
Answer Posted / krishna kanth
#include<stdio.h>
main()
{
int setbit=1;
int number=16;//for example
int numBitSet=0;
clrscr();
while(setbit<=number)//important and optimized condition
{
if(number&setbit)
numBitSet++;
setbit=setbit<<1;
}
printf("%d",numBitSet);
getch();
}
Is This Answer Correct ? | 10 Yes | 3 No |
Post New Answer View All Answers
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
Why is c called a structured programming language?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
What is the difference between functions abs() and fabs()?
How to Throw some light on the splay trees?
What are the advantage of c language?
swap 2 numbers without using third variable?
What is pointer to pointer in c?
Not all reserved words are written in lowercase. TRUE or FALSE?
How can I do graphics in c?
How would you rename a function in C?
Why should I use standard library functions instead of writing my own?
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250
Define Spanning-Tree Protocol (STP)