**Decimal to octal program in c** is decimal to octal conversion in c.

**What is a decimal number?**

Numbers we use in everyday life from 0 to 9 are the decimal numbers

**What is the octal number?**

A number expressed in base 8. The numbers from 0 to 7 are octal numbers.

**How to convert decimal to octal**

Decimal to binary conversion in c: We divide the decimal number by 8 And write down the reminder. do this until the final result is 0.

**Decimal to the octal formula :**

Simply divide a binary number by 8 and write down a reminder.

**Decimal to octal example**

## Decimal to octal algorithm

- Declare variable
- Divide decimal number by 8 continuously
- And store result as an octal number
- If final result is zero then stopPrint octal number

## Decimal to octal program in c

#include<stdio.h> main() { int dec,temp,i,j=1,octal=0; printf("Enter the decimal number : "); scanf("%d",&dec); temp=dec; while(temp!=0) { i=temp%8; octal=octal+(i*j); temp=temp/8; j=j*10; } printf("Octal number : %d\n",octal); }

**Output :**