delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/28/20:52:23

Sender: nate AT cartsys DOT com
Message-ID: <37781835.8ECF1154@cartsys.com>
Date: Mon, 28 Jun 1999 17:49:57 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.10 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: A PARSE ERROR I DON"T KNOW WHAT TO DO WITH!!!!
References: <AAtd3.11224$5i7 DOT 7097 AT news DOT rdc1 DOT va DOT home DOT com>
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019