# How do you Convert Decimal to Octal and Hexadecimal?

We can convert decimal to octal by following these steps:
1. After dividing the number by 8, we store the remainder in an array
2. Divide the number by 8 now
3. Repeat the above two steps until the number becomes equal to zero
4. Now, print the array in reverse orderÂ

We can convert decimal to hexadecimal by following these steps:

1. After dividing the number by 16, store the remainder in a temporary variable temp1.Â
2. If the temp1<10, insert( 48+temp1) into the array otherwise insert (55+temp1) into the array.Â
3. Now, divide the number by 16Â Â
4. Repeat the above steps until the number becomes equal to zeroÂ
5. Now, print the array in reverse order

#### Related Topics

Share with friends

## Customize your course in 30 seconds

##### Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
Ashhar Firdausi
IIT Roorkee
Biology
Dr. Nazma Shaik
VTU
Chemistry
Gaurav Tiwari
APJAKTU
Physics
Get Started