Program to convert a number from binary to octal using C, C++, Java and other programming languages is discussed here. Firstly let us look at an example to do this.
For example, Consider the binary number 1111 which has to be converted to octal. Divide the binary number into groups of three from right to left. 1111 can be grouped as 001 111 Now, find the octal number for each group. Three-bit binary numbers from (000 to 111) have equal decimal and octal representations. Hence, the octal numbers for binary numbers in the range (000 to 111) are same as that of the decimal numbers. The octal number of 001 is 1 and 111 is 7. The octal equivalent of 1111 is 17.
Time complexity: O(n)