The Binary Number System
In the familiar base 10 system, the smallest (rightmost) digit of a number is the ones place (100). The next digit is in the tens place (101), and the next one is in the hundreds place (102) and so forth. Thus the number 122 is really (1 * 102) + (2 * 101) + (2 * 100). Each digit is worth a power of 10 more than the digit to the right of it in the base 10 system.
Similarly, in the binary number system, the smallest (rightmost) digit of a number is the ones place (20). The next digit is in the twos place (21), and the next one is in the fours place (22) and so forth. Thus the number 101 is really (1 * 22) + (0* 21) + (1 * 20) = 5. Each digit is worth a power of 2 more than the digit to the right of it in the base 2 system.
Write a program to display all of the binary digits of a number. You program should continue
to display binary digits of numbers until the user wishes to stop.
Hint:
To find a binary digit, print the remainder number % 2, then replace the number with number/2. Repeat this process until the number is 0.
SAMPLE OUTPUT:
Enter a number for binary conversion=>13
Binary Number
1
0
1
1
Another number to enter =? , type 1 for yes and any other number for no=>1
Enter a number for binary conversion=>10
Binary Number
0
1
0
1
Another number to enter =? , type 1 for yes and any other number for no=>2