Basically Octal numbers can go up to 8 and Hex go up to 16.
So Decimal 7 = Octal 7, however a decimal value of 8 = an Octal value of 10. Add one to the next number and then keep going up again:
Decimal 9 = Octal 11
D 10 = O 12
D 16 = O 20
D 17 = O 21
D 24 = O 30
D 32 = O 40
D 40 = O 50
D 48 = O 60
D 56 = O 70
D 63 = O 77 - Once again the second number cannot pass 8 so you move to the third.
D 64 = O 100
D 72 = O 110
D 75 = O 113
For Hex take the 0x away first off. That's just there to let the C++ compiler know that you want the number to be used as a hex value.
D 1 = H 1
D 9 = H 9
As soon as the decimal goes to 10 hex switches to the letters A through F.
D 10 = H A
D 15 = H F
Then just use the same method for octal. Once the hex value can't go any higher for the first digit move to the second and add one.
D 16 = H 10
D 31 = H 1F
D 32 = H 20
D 48 = H 30
D 64 = H 40
D 73 = H 49
D 74 = H 4A
D 75 = H 4B
It is tough to explain but I hope that helps.