In this tutorial, we will learn to write a program in c to convert a decimal number into an octal number. Here we will use the division by 8 concepts to convert it into an octal number.

Before moving towards the writing program let’s know about the Octal numbers.

## What is an Octal Number?

An **octal number** is a number that is expressed in the **base-8 numeral system**. This expression contains only numbers 0 to 7. Here in the Octal system, each place is a power of 8.

**For example**

If we convert **108 **in the octal then output will be 154.

Because in octal, the** base is 8**.

After calculation it will be convert into decimal like 1*8^2 + 5 * 8^1 + 4 * 8^0 = 64 + 40 + 4 = 108

By performing the calculation above we see why Octal 154 is equal to 108 in decimal.

## C Program to convert decimal into octal

```
#include <stdio.h>
int main()
{
int arr[10], num, i, j;
printf("Program to Convert Decimal Number into Octal\n");
printf("Please Give a Number to Convert in Octal: ");
scanf("%d", &num);
printf("Octal Number of %d is = ",num);
for(i = 0; num > 0; i++)
{
arr[i] = num % 8;
num = num / 8;
}
for(j = i - 1; j >= 0; j--) {
printf(" %d ", arr[j]);
}
printf("\n");
return 0;
}
```

**Output**

```
Program to Convert Decimal Number into Octal
Please Give a Number to Convert in Octal: 34
Octal Number of 34 is = 4 2
```

## Also Prepare Below Important Question

- Python Program to add two number using Recursion
- Python Program to Find Highest Frequency Element in Array
- Python Program to Merge two Arrays
- Perform left rotation by two positions in Array Using Python
- Python Program to Delete Element at Given Index in Array
- Python Program to Delete element at End of Array
- Python Program to Copy one String to Another String
- Python Program to Remove Repeated Character from String
- Print highest frequency Character in String in Python
- Python Program to Convert lowercase vowel to uppercase
- Convert Celsius to Fahrenheit in Python
- Leap Year Program in Python
- Python Program to convert Decimal to Octal number
- Python Program to Convert Decimal Number into Binary
- Find all Pairs Whose Sum is Equal to Given number in Python
- Python Program to Replace First Vowel With ‘-‘ in String
- Python Program to find Prime factors of given integer
- Python Program to Print Prime Number in given range
- Java Program to Perform Left Rotation on Array Elements by Two
- Java Program to Perform Right Rotation on Array Elements by Two

## Interview Questions Categories

### C Programming Interview Preparation

### Core Java Programming Interview Preparation

- Core Java Programming Coding Questions
- Core Java Pattern Programming Questions
- Core Java Programming Interview Questions