# Java program to to convert Octal number into Decimal number

Octal to Decimal: How to Convert

Octal to decimal conversion is one of the most commonly taught problem solving exercises in computer basics. So is there an octal to decimal formula? Yes, an octal number can be converted to a decimal number using the following formula:

Decimal Form = Ʃ(ai x 8i)

In this formula, ‘a’ is the individual digit being converted, while ‘i‘ is the number of the digit counting from the right-most digit in the number, the right-most digit starting with 0.

For example:

Convert (765)8 into decimal:

(765)8 = (7 x 82) + (6 x 81) + (5 x 80)

= (7 x 64) + (6 x 8 ) + (5 x 1)

= 448 + 48 + 5

= 501

Hence (765)8 = (501)10

Similarly,

(1336)8 = (734)10

(5467)8 = (2871)10

(6345)8 = (3301)10(

(76534)8 = (32092)10

(724635)8 = (240029)10

Try out yourselves!

How the Program works?
This program accepts the octal number from the user, saves individual digits to individual spaces in the array in the 1st ‘for’ loop and applies the above formula on them in the second ‘for’ loop.

Output:

Tested in Eclipse.

The following two tabs change content below.