← Back to Structs
Question 418
Simplify a Fraction
Simplify a Fraction
Astruct Fractionholdsnum = 6andden = 8. Reduce it to lowest terms by dividing both fields by their greatest common divisor (GCD), then print the result asnum/den(see Expected Output). The GCD of 6 and 8 is 2, giving3/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.