CPSC170A
Fundamentals of Computer Science II

Lab 12

More Structures

Fraction

Create a structure that represents fractional numbers and the following functions:

// Prints a fraction in the form "numerator / denominator".
void print_fraction(const Fraction& fraction)

// Returns a new fraction that is the sum of lhs and rhs.
// Note, the returned fraction is not necessarily the most
// simple fraction.
Fraction add(const Fraction& lhs, const Fraction& rhs)

// Returns a new fraction that is equivalent to the input
// fraction reduced to its lowest terms.
Fraction reduce(const Fraction& fraction)

For each function, other than print_fraction, include a function that tests it.