C Programming Code Examples C > Conversions Code Examples This program takes a octal number as input and converts it into decimal number. This program takes a octal number as input and converts it into decimal number. - Take the octal number as input and store it in the variable octal. - Initialize the variables decimal and j to zero. - Obtain the remainder and quotient of the octal number. Multiply the remainder by powers of 8 using function pow(8, j++), add this value to the variable decimal and store it in the variable decimal. - Override the variable octal with quotient. - Repeat the steps 3 and 4 with the quotient obtained until the quotient becomes zero. - Print the variable decimal as output. #include <stdio.h> #include <math.h> int main() { long int octal, decimal = 0; int j = 0; printf("Enter any octal number: "); scanf("%ld", &octal); while (octal != 0) { decimal = decimal +(octal % 10)* pow(8, j++); octal = octal / 10; } printf("Equivalent decimal value: %ld",decimal); return 0; }