I am having some syntax errors with this program. My compiler is borland. What am I doing wrong?
Code:#include <iostream.h> int GCD(int a, int b ) { int remainder, quotient, divisor, numerator; if (a > b) { remainder=a%b; quotient=a/b; divisor=b; }else{ remainder=b%a; quotient=b/a;divisor=a; } while( remainder!=0 ) { numerator=divisor; divisor=quotient; remainder=numerator%divisor; quotient=numerator/divisor; } return divisor; } int simplify1(int a, int GCD ) { int product1; { do{ product1=a / GCD; }while ( a!=0); } return product1; } int simplify2(int b, int GCD ) { int product2; { do{ product2=b / GCD; }while ( b!=0 ); } return product2; int main() { int w, x; char junk; cout << "This program allows calculating the GCD\n"; cout << "Value of first numerator: "; cin >> w; cout << "Value of first denominator: "; cin >> x; cout << "\nThe Greatest Common Divisor of " << w << " and " << x << " is " << GCD(w, x) << endl; cout << "\nThe simplified fraction is " << simplify1(w,GCD(w, x)) << " and "<< simplify2(x,GCD(w, x)) endl; cin >> junk; //This input allows for display. return 0; }



LinkBack URL
About LinkBacks



eclaration syntax error