The following program computes the sum of two fractions and reduces the resultant to lowest terms. However, I keep getting a parse error before '>>' on lines 27 and 30. Help?!?!

--------------------------------------------------------------------------------------
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

int gcdenom;
int sumnum, sumdenom;

void GCD ( int numerator, int denominator ) {
int remainder = denominator % numerator;
if ( remainder != 0 ) {
return GCD ( remainder, numerator );
}
gcdenom = numerator;
}

void AddFractions ( int numer1, int denom1, int numer2, int denom2 ) {
sumnum = ( numer1*denom2 ) + ( denom1*numer2 );
sumdenom = ( denom1*denom2 );
}


int main () {
int a, c;//Numerators
int b, d;//Denominators
int x, y;//Product - (num, denom)
cout << "Input a fraction (a/b): "
cin >> a; //line 27
cin >> b;
cout << "Input a second fraction (c/d): "
cin >> c; //line 30
cin >> d;
if ( cin.good() && b != 0 && d != 0 ) {
AddFractions ( a, b, c, d );
}
GCD ( sumnum, sumdenom );
x = sumnum/gcdenom;
y = sumdenom/gcdenom;
cout << a << "/" << b << " + " << c << "/" << d << " = " << x << "/" << y << endl;
}

Reply via email to