Assignment

Hexadecimals are often used in computer systems programming. How do you convert a decimal number to a hexadecimal number? To convert a decimal number d to a hexadecimal number is to find the hexadecimal digits hn, hn-1, …, h2, h1, and h0 such that

d = hn x 16n + hn-1 x 16n-1 + … + h2 x 162 + h1 x 161

These hexadecimal digits can be found by successively dividing d by 16 until the quotient is 0. The remainders are h0, h1, h2, …, hn-2, hn-1, and hn.

Specifications

Example

Below is an example execution of the task. The text in red represents user input and logically is not printed by your program.

Enter a decimal number:26
The hexadecimal representation of 26 is 1A