Write a program that works as follows:
Prompt the user to enter a decimal integer.
Prompt the use to select a base from 2(binary), 8(octal) and 16(hexadecimal).
Convert the decimal integer to the selected base.
Print the result.
Sample
Input:
123
16
Output:
123(decimal) = 7B(hexadecimal)
Input:
123
2
Output:
123(decimal) = 1111011(binary)
Input:
123
8
Output:
123(decimal) = 173(octal)
Comments
Leave a comment