CJCoding With Joseph

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:

3/4

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
Topics:
Structs
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.