# Logic to convert the floating point no to fraction(numerator/denominator) format

• 08-25-2007
tanmay_solanki
Logic to convert the floating point no to fraction(numerator/denominator) format
Please tell me logic of this program without using structures.
Problem: given a no exp:3 you should display all combination of unique fractions in ascending order like as shown in example
EXP:
input: 3
o/p:1/3 1/2 2/3 1/1

hint:convertion Logic to convert the floating point no to fraction(numerator/denominator) format without using structures.
examples:
0.2 can be converted to 1/5 format
.5 can be conveted to the 1/2 format
2/3 can be conveted to the .667
• 08-25-2007
zacs7
.5 is not 1/5, it's 1/2, See the rules regarding homework.

* Make sure the decimal is terminating, ie finite, 2/3 is not finite you're going to have to do some approximation going from .667 -> 2/3
* See http://homepage.smc.edu/kennedy_john/DEC2FRAC.PDF or research yourself

If you have any specific questions, ask.
• 08-25-2007
tanmay_solanki
thanks
thanks for guiding me.I will be glad to have more replys from you for the future threads.
• 08-26-2007
Salem
> 0.2 can be converted to 1/5 format
Consider that say 0.125 can be written as 125/1000
Now research GCD and GCF to see how you might reduce it to 1/8