|
Well we got an assignment of 20 questions, i am able to solve 18 of them but these 2 questions are getting off my brain, can anyone please help me to make these
15. Write an algorithm that inputs two fractions in the form a/b and c/d, and outputs their sum in the form p/q cancelled down to its simplest form.
--------------------
19. FRACTIONS TO DECIMALS: Write a program that will accept a fraction of the form N/D, where N is the numerator and D is the denominator, that prints out the decimal representation. If the decimal representation has a repeating sequence of digits, it should be indicated by enclosing it in brackets. For example, 1/3 = .33333333...is denoted as .(3), and 41/333 = .123123123...is denoted as .(123).
Typical conversions are:
1/3 = .(3)
22/5 = 4.4
1/7 = .(142857)
3/8 = .375
45/56 = .803(571428)
Test your program with the fractions above and the fraction 11/59.
Sample Run
ENTER N,D : 1,7
1/7 = .(142857)
|