Convert Octal to Decimal in C


Prev Tutorial Next Tutorial

Convert Octal to Decimal Program in C

In this types of program we takes a Octal number as input and converts it into Decimal number. To convert Octal to Decimal number first accept Octal as a input then convert into equivalent Decimal number

Steps to Convert Octal to Decimal Number

  • Start the decimal result at 0.
  • Remove the most significant octal digit (leftmost) and add it to the result.
  • If all octal digits have been removed, you are done. Stop.
  • Otherwise, multiply the result by 8.
  • Go to step 2.

Convert Octal to Decimal in C


void main()
    long int octal, decimal = 0;
    int i = 0;
    printf("Please Enter any Octal Number: ");
    scanf("%ld", &octal);
    while (octal != 0)
        decimal =  decimal +(octal % 10)* pow(8, i++);
        octal = octal / 10;
    printf("Equivalent decimal value: %ld",decimal);

Output 1

Please Enter any Octal Number: 82
Equivalent Decimal Value is: 66

Output 2

Please Enter any Octal Number: 16
Equivalent Decimal Value is: 14

Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: or 9999595223

wifi cctv camera

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223
wifi cctv camera

Wifi CCTV Camera RS:1200 to 2499.

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: or 9999595223 Try this Keyword C++ Programs