Extension exercise
Write a program that converts a number between 0 and 255 into its 8-bit binary representation.
Print each bit on a separate line, starting from the least significant bit (rightmost) to the most significant bit (leftmost).
Hint: Use modulus (% 2) to find the current bit (0 or 1), then integer division (// 2) to move to the next bit. Repeat this 8 times.
The program should prompt:
Enter a number (0-255):
8 lines, each containing a single 0 or 1, from least significant to most significant bit.
Input:
254
Output:
0
1
1
1
1
1
1
1
This reads as 11111110 from bottom to top, which is 254 in binary.