Saved Bookmarks
| 1. |
Write a c programme to find the number of 1 in a binary number |
|
Answer» Answer: For example, binary REPRESENTATION of 4 is 100 and the number of ONES in it is 1. Similarly, binary representation of 99 is 1100011 and the number of ones in it is 4. ... Code: VOID countOnes (int n) { int COUNT=0; while (n!=0) { n = n & (n-1); count++; } |
|