hello, I am writing a c++ program to reduce/simplify a fraction 21/14 -> 3/2.
I have to use struct Fraction and write 3 functions enter(&fraction),simplify(&fraction) display(fraction). I have to pass by address of an instance of a Fraction type in a pointer parameter for enter() and simplify. Here is the program I managed to write. It works. I want to know is there any way I can improve or any errors. Thanks!
I think you could break/exit out of the loop once you've found the greatest common divisor(gcd), because every other common divisor should be contained in the gcd. So you're not doing any unnecessary work.
Also don't your enter, simplify and display functions return Fraction structs, in which case how does it compile when you never return anything in any of those functions