C Programming Code Examples C > Conversions Code Examples this program takes a decimal number as input and converts to octal number. this program takes a decimal number as input and converts to octal number. Take a decimal number as input. Divide the input number by 8 and obtain its remainder and quotient. Store the remainder in the array. Repeat the step 2 with the quotient obtained. Do this until the quotient becomes zero. Print the array in the reverse order to get the output. #include <stdio.h> int main() { long decimalnumber, remainder, quotient; int octalNumber[100], i = 1, j; printf("Enter the decimal number: "); scanf("%ld", &decimalnumber); quotient = decimalnumber; while (quotient != 0) { octalNumber[i++] = quotient % 8; quotient = quotient / 8; } printf("Equivalent octal value of decimal no %d: ", decimalnumber); for (j = i - 1; j > 0; j--) printf("%d", octalNumber[j]); return 0; } Take a decimal number as input and store it in the variable decimalnumber. Copy the variable decimalnumber to the variable quotient. Divide the variable quotient and obtain its remainder and quotient. Store the remainder in the array octalNumber and override the variable quotient with the quotient obtained. Repeat the step 3 until the quotient becomes zero. When it becomes zero, print the array octalNumber in the reverse order to get the output.