Simplify a Fraction
hardQuestion 418A 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
Sign in to use hintsTopics
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.