Modify the add() function in the
previous exercise
so that it works with the following main program.
Note that in this version, the function returns a data type
Rational.
Rational add(Rational a, Rational b);
int main()
{
const unsigned short N = 5;
Rational a[N] = { {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5} };
Rational b[N] = { {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1} };
Rational c[N];
int i;
for (i=0; i<N; i++)
{
c[i] = add(a[i], b[i]);
print(a[i]);
cout << " + ";
print(b[i]);
cout << " = ";
print(c[i]);
cout << endl;
}
return 0;
}