Computer Science, asked by sameed17khan, 7 months ago

Write a function to convert a decimal number to octal using stack in python.​

Answers

Answered by Anonymous
2

Answer:

Python doesn’t support any inbuilt function to easily convert floating point decimal numbers to octal representation. Let’s do this manually.

Approach : To convert a decimal number having fractional part into octal, first convert the integer part into octal form and then fractional part into octal form and finally combine the two results to get the final answer.

For Integer Part, Keep dividing the number by 8 and noting down the remainder until and unless the dividend is less than 8 and copy all the remainders together.

For the Decimal Part, Keep multiplying the decimal part with 8 until and unless we get 0 left as fractional part. After multiplying the first time, note down an integral part and then again multiply the decimal part of new value by 8 and keep doing this until perfect number is reached.

hope this helps you... plz Mark as BRAINLIEST answer

Answered by SP85
1

It's simple

Just go through steps which I will guide you

1)Input the decimal number.

2)Divide the decimal number by 8.

3)Store the remainder.

3)Repeat steps 2 and 3 until the number can be divided.

4)Print the reverse of the remainder, which is the octal equivalent of the decimal number

Got the answer

Similar questions