I see these two question in my book, the first one I make it out, but the second one puzzles me, how ?
12.8.5 Binary to Decimal
Write a program that asks the user to input a binary string (e.g., “11100010101”). Note that the input is a string, not a number. The string specifies a binary number. The program then is to convert the binary number which the string specifies into a decimal number and output the result. Your output should look like this:
Enter a binary string: 101
101 = 5 in decimal.
Press any key to continue.
12.8.6 Decimal to Binary
Write the reverse conversion of Exercise 12.8.5. That is, write a program that asks the user to input a decimal number (this time it is not a string but a number). The program then is to convert the decimal number which the user entered into a binary string(e.g., “11100010101”) and output the result. Your
output should look like this:
Enter a decimal number: 14
14 = 1110 in binary.
Press any key to continue.