This C Program Converts the given Octal to Decimal. Octal is a numbering system that uses eight digits, 0 to 7, arranged in a series of columns to represent all numerical quantities. Each column or place value has a weighted value of 1, 8, 64, 512, and so on, ranging from right to left. Decimal is a term that describes the base-10 number system commonly used by lay people in the developed world.
Here is source code of the C program to Convert Octal to Decimal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Convert Octal to Decimal
long int octal, decimal = 0;
int i = 0;
printf("Enter any octal number: ");
while (octal != 0)
decimal = decimal +(octal % 10)* pow(8, i++);
octal = octal / 10;
printf("Equivalent decimal value: %ld",decimal);
Output: $ cc pgm3.c -lm $ a.out Enter any octal number: 67 Equivalent decimal value: 55
Sanfoundry Global Education & Learning Series – 1000 C Programs.
If you wish to look at other example programs on Simple C Programs, go to Simple C Programs. If you wish to look at programming examples on all topics, go to C Programming Examples.