0

```
void Rational::reduce(Rational &f3){
int tnum, tden, temp, gcd;
tnum = labs(numerator); // use non-negative copies
tden = labs(denominator); // (needs cmath)
if(tden==0 ){ // check for n/0
cout << "Illegal fraction: division by 0"; exit(1); }
else if( tnum==0 ){ // check for 0/n
numerator=0; denominator = 1; return; }
// this ‘while’ loop finds the gcd of tnum and tden
while(tnum != 0)
if(tnum < tden){ // ensure numerator larger
temp=tnum; tnum=tden; tden=temp; // swap them
tnum = tnum - tden;} // subtract them
gcd = tden; // this is greatest common divisor
numerator = numerator / gcd; // divide both num and den by gcd
denominator = denominator / gcd; // to reduce frac to lowest terms
} //ends function reduce
void Rational::normalize(Rational&){
if(denominator < 0){
numerator = numerator * -1;
denominator = denominator * -1;}
} //ends function normalize
//sets the numerator and denominator to 0
void Rational::sglfrac() {
cout << "\nnumerator: "; cin >> numerator;
cout << "denominator: "; cin >> denominator;
} //end function sglfrac
void Rational::add(Rational f1, Rational f2 ) {
// a / b + c / d = [n](a * d + b * c) [d](b * d)
numerator = (f1.numerator * f2.denominator) + (f1.denominator * f2.numerator); //adds the numerator
denominator = (f1.denominator * f2.denominator); //adds the denominator
} //end function add
```

so far I've been trying to get the fraction to be reduced and normalized in the add function and I'm trying to use pass with reference but I am completely lost when it comes to passing by reference

so far all I've understood is passing by reference creates a copy of the item