Mail Archives: djgpp/1999/06/28/20:52:23
Gregory Akselrod wrote:
>
> I have an error and I can't seem to resolve it. Attached to this e-mail is
> the source code to my code. Every time I try to compile it I get an error:
>
> 4_function_calc.cc:48: parse error before `else'
>
> I've tried so many things to fix it. I'm just a newbie so this is probably
> very simple to fix. Please tell me what's wrong and if you would be so kind
> edit the source code so I can see what's wrong. Thankyou.
>
> -Greg Akselrod
>
> Name: 4_function_calc.cc
> 4_function_calc.cc Type: unspecified type (application/octet-stream)
> Encoding: x-uuencode
Your code around line 32 looks like:
-------------------------
if (Wdivide == 1);
{
cout << "Please enter the dividend: ";
cin >> dividend;
cout << "\nPlease enter the divisor: ";
cin >> divisor;
quotient = Divide(dividend, divisor);
divisor1 = divisor;
dividend = dividend;
remainder = Remainder(dividend1, divisor1);
cout << "\nThe answer is: ";
cout << quotient;
cout << " with a remainder of: ";
cout << remainder << endl;
}
else
cout << "Would you like to multiply? 0-no, 1-yes: ";
--------------------------------------------
You need to eliminate the semicolon after the `if' line. Otherwise it
reads as "if Wdivide == 1 then do nothing", the following code is
executed always, and the else makes no sense.
You probably also need to put braces around the else block. Currently
it is only the "Would you like to multiply" line.
And lastly, might I suggest you use a more readable indentation style.
Btw, generic language questions are more on-topic in places like
comp.lang.c++.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -