C Program to Convert Octal to Decimal

Let’s understand how to Octal Number to Decimal Number in C Programming Language.

C Program to Convert Octal to Decimal

#include<stdio.h>

#include<conio.h>

#include<math.h>

/*Learn C Programming at CodeAtGlance.com*/

void main()

{

                clrscr();

                long int oct_number, dec_number=0;

                int i=0;

                printf("Enter any Octal Number : ");

                scanf("%ld",&oct_number);

                while(oct_number!=0)

                {

                                dec_number = dec_number + (oct_number%10) * pow(8, i);

                                i++;

                                oct_number=oct_number/10;

                }

                printf("Equivalent Decimal Value: %ld",dec_number);

                getch();

}

 

Leave a Reply