I have to agree with Terminator1337 on this, the code for the main()
function in particular is wretched (not to mention incorrect - in C++, main()
should always return an int
, with no exceptions to the rule). The fact that it appears to have been given to you by the instructor makes this even less acceptable.
As for the ReduceFraction()
function, simply think through how you would do it manually: you first find the greatest common divisor of the numerator and the denominator, then divide them each by said divisor. Simple, no?
Getting the common denominator of two ratios is almost as easy: you multiply the denominators, then multiply num1 by den2 for the new num1, and num2 by den1 for the new num2.