CJCoding With Joseph
15free / daySign inCreate account

Simplify a Fraction

A struct Fraction holds num = 6 and den = 8. Reduce it to lowest terms by dividing both fields by their greatest common divisor (GCD), then print the result as num/den (see Expected Output).

The GCD of 6 and 8 is 2, giving 3/4. You will need to compute the GCD yourself (the Euclidean algorithm works well). There is no trailing newline.

Expected Output:

3/4

= newline. No newline after the last line.

Hints4 available
Topics:
Structs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.