Explore
Placement Prep

Edit

Edit

# Convert decimal to octal number in C, C++, Java and Python | FACE Prep

Published on 10 Mar 2020

Program to convert a number from decimal to octal is discussed here. Given a decimal number as input, which has to be converted to its equivalent octal number.

For example, decimal number 200 has to be converted to octal.

200 / 8 = 25 , rem = 0
25 / 8 = 3 , rem = 1
3 / 8 = 0 , rem = 3
﻿
The equivalent octal number of the decimal number 200 is 310.


## Algorithm to convert a number from decimal to octal

1. Input the decimal number.
2. Divide the decimal number by 8.
3. Store the remainder.
4. Repeat steps 2 and 3 until the number can be divided.
5. Print the reverse of the remainder, which is the octal equivalent of the decimal number.

## Program to convert a number from decimal to octal

C
C++
Java
Python 3

Output
Input- Enter a decimal number:200 Output- Equivalent octal number :310

﻿Time complexity: O(n)

Recommended Programs