Example 96: Print Binary Value
Learn how to print the binary value of a number using bitwise operators.
We'll cover the following...
We'll cover the following...
Problem
Define a showBits() function that would print the binary value stored in a one-byte entity.
Remember that you can only use bitwise operators to solve this challenge.
Example
| Input | Output |
|---|---|
| 10 | 00001010 |
| 15 | 00001111 |
| 23 | 00010111 |
| 32 | 00100000 |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.