You all are aware of Stacks. It performs two basic operations push and pop. The push operation adds an element to the top of the list, or initializing the stack if it is empty and the pop operation removes an item from the top of the list. Using these operations, we have converted a decimal number into Hexadecimal .

- Divide the decimal number by 16
- Treat the division as an integer division. Write down the remainder (in hexadecimal).
- Divide the result again by 16.
- Treat the division as an integer division. Repeat step 2 and 3 until result is 0.
- The hex value is the digit sequence of the remainders from the last to first.

HEXADECIMAL 0 1 2 3 4 5 6 7 8 9 A B C D E FDECIMAL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

#### Convert Decimal to Hexadecimal using Stack

#### When you run the program, the output will be:

Enter Positive Integer :21Hexadecimal : 15

Very good program Mr.Achchuthan......keep it

ReplyDeleteActually this blog is very helpful for my data structure algorithms studies......

ReplyDelete## Post a Comment

Thank you for vising