The 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,nnConsider the binary number 1111 which has to be converted to octal.nDivide the binary number into groups of three from right to left.nn1111 can be grouped as 001 111nnNow, find the octal number for each group.nnThree-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 nthat of the decimal numbers.nnThe octal number of 001 is 1 and 111 is 7.nnThe octal equivalent of 1111 is 17.n
@@coding::1@@
Time complexity: O(n)
Recommended Programs