Sequential Programming

Write a program that translates an integer consisting of upto 4 binary digits into its binary equivalent.


Now that the binary number is split apart, how do we change the digits into the decimal equivalent?
Notice that digit4 is the 8's place holder, digit 3 is the 4's place holder, digit2 is the 2's place holder and the result in binary_string is the 1's place holder. So, we could use:
digit4*8 + digit3*4 + digit2*2 + binary_string
Here's the code Here's the Output

OR

digit4*(2*2*2) + digit3*(2*2) + digit2*(2) + binary_string
Notice that digit4 is multiplied by three 2s, digit3 by two 2s,... Here's a neater solution and the output

Notice that the binary string that is printed at the end of the code is incorrect. We need to print it at the beginning instead.
solution and output