➽ Program:-
binary_number
= int(input("Enter the Binary Number: "))
octal_number
= 0
octal_arr =
[]
i = 0
product = 1
temp = 1
while
binary_number!=0:
rem = binary_number % 10
octal_number += rem * product
if(temp%3 == 0):
octal_arr.insert(i, octal_number)
product = 1
octal_number = 0
temp = 1
i = i+1
else:
product = product*2
temp = temp+1
binary_number = int(binary_number / 10)
if(temp !=
1):
octal_arr.insert(i, octal_number)
print("Octal
Value is ", end="")
while(i
>= 0):
print(str(octal_arr[i]), end="")
i = i-1
➽ Output:-
0 Comments
Please do not enter any spam link in the comment section.