C++ 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


(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.

Tested in: Visual Studio 2010/Visual C++

The following two tabs change content below.

Lalit Mali

Lalit is a technology enthusiast, a programming lover and currently an Android fan.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">