Saved Bookmarks
| 1. |
Write A Constant Time Consuming Statement Lot Finding Out If A Given Number Is A Power Of 2? |
|
Answer» If n is the GIVEN NUMBER, then the expression (n & (n-1)) = 0 gives the logical output DEPICTING if it is a power of 2 or not, if (n & (n-1) == 0) PRINTF (“The given number is a power of 2”); If n is the given number, then the expression (n & (n-1)) = 0 gives the logical output depicting if it is a power of 2 or not, if (n & (n-1) == 0) printf (“The given number is a power of 2”); |
|