1. ## syntax errors

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;
}

2. What and where?

3. 1. posting error text will be helpful
2. #include <iostream>
3. you should use std namespace
4. simplify1 and simplify2 have endless loop
5. GCD does not check that values are bigger than 0

4. Vart, for your points #2 and #3, seeing as how he's using Borland, I wouldn't be surprised if it was a version that didn't support the new <iostream>/namespace std include style.

5. Yes, my college is cheap and wont buy visual studio so I have to use the ".h" after everything.

6. there is a free MSVC++ Expert compiler

7. Error: sort and search hoskins beta v1.cpp(10,1):Declaration syntax error
Error: sort and search hoskins beta v1.cpp(53,6):Expression syntax
Error: sort and search hoskins beta v1.cpp(53,6):'bubblesort(long *,int)' cannot return a value
Error: sort and search hoskins beta v1.cpp(53,6):Return statement missing ;
Error: sort and search hoskins beta v1.cpp(58,6):Declaration syntax error
Error: sort and search hoskins beta v1.cpp(136,1):Compound statement missing }

8. My instructor is using borland as well. I did a little work in visual studio once and sent it to him and he couldnt figure out that he had to change it from "using namespace std;".

9. Originally Posted by vart
there is a free MSVC++ Expert compiler
Yes, but if he wants his code to compile in the labs at his school, I doubt he has the option of using a different compiler. Plus if he's only working in the school labs, he wouldn't even have the ability to install that.

10. those smilys arent supposed to be there.

11. Originally Posted by nesagsar
those smilys arent supposed to be there.
errors are from another project
there is no bubblesort function in this one

12. A school which isn't teaching you about namespaces and how to use them really isn't preparing you for a programming career when you're done.

Namespaces appeared in 1998, which means they'll be about 10 years old by the time you get through college.

"Sorry kid, you don't know about namespaces" is really gonna suck come job hunting time.

There is simply NO excuse for not using any one of the current crop of C++ compilers on the basis of cost, because they're all free. It's just down to lame tutors just teaching what they know, no matter how old and out of date it is.
Try and explain this to them, especially if you're the one handing over the dollars for the course.

13. sorry about the errors, I am trying to debug 4 programs at once.

14. these are the correct errors

Info :fraction hoskins beta v2.cpp: out of date with destination fraction hoskins beta v2.obj
Info : fraction hoskins beta v2.cpp: source date 11:51:00 AM 12/11/2006 destination date <unknown>
Info :Compiling C:\Documents and Settings\labpc\Desktop\fraction hoskins beta v2.cpp
Error: fraction hoskins beta v2.cpp(39,5)eclaration syntax error
Error: fraction hoskins beta v2.cpp(40,8)eclaration terminated incorrectly
Error: fraction hoskins beta v2.cpp(65,40):Statement missing ;

15. and the stupid smilys persist.