This C Program Converts the given Decimal to Octal. 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 Decimal to Octal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C program to Convert Decimal to Octal`

`*/`

`#include <stdio.h>`

int main()

`{`

long decimalnum, remainder, quotient;

int octalNumber[100], i = 1, j;

printf("Enter the decimal number: ");

scanf("%ld", &decimalnum);

quotient = decimalnum;

while (quotient != 0)

`{`

octalNumber[i++] = quotient % 8;

quotient = quotient / 8;

`}`

printf("Equivalent octal value of decimal no %d: ", decimalnum);

for (j = i - 1; j > 0; j--)

printf("%d", octalNumber[j]);

return 0;

`}`

advertisements

Output: $ cc pgm11.c $ a.out Enter the decimal number: 68 Equivalent octal value of decimal no 68: 104

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

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.