C Programming Code Examples C > Conversions Code Examples C Program to Convert Octal Number to Decimal Number C Program to Convert Octal Number to Decimal Number The program takes the octal number (entered by user) as input and converts it into a decimal number using function. #include <stdio.h> #include <math.h> /* This function converts the octal number "octalnumber" to the * decimal number and returns it. */ long octalToDecimal(int octalnumber) { int decimalnumber = 0, temp = 0; while(octalnumber != 0) { decimalnumber = decimalnumber + (octalnumber%10) * pow(8,temp); temp++; octalnumber = octalnumber / 10; } return decimalnumber; } int main() { int octalnumber; printf("Enter an octal number: "); scanf("%d", &octalnumber); printf("Equivalent decimal number is: %ld", octalToDecimal(octalnumber)); return 0; }