Skip to main content
gamedev.net
🔒 Locked

Parse errors...

Started by USArmyMortars Sep 10, 2004 at 5:23 PM 5 replies 1.1k views
Original Post
USArmyMortars
USArmyMortars
can anyone see what the problem is?
int main()
{
  float a, b, c, r1, i1, r2, i2;
  
  std::cout << "Enter the coeffitient 'a': ";
  std::cin >> a;
  std::cout << "Enter the coefficient 'b': ";
  std::cin >> b;
  std::cout << "Enter the coefficient 'c': ";
  std::cin >> c;
  
  r1 = (-b + (sqrt(Squared(b)*(-4*a*c))/(2*a)); //ERROR: PARSE ERROR BEFORE ';' TOKEN
  r2 = (-b - (sqrt(Squared(b)*(-4*a*c))/(2*a));	//ERROR: PARSE ERROR BEFORE ')' TOKEN
  
  std::cout << "#1: " << r1 << "    #2: " << r2;

return 0;
}
-thanks
HHC 1st Battalion, 5th Infantry Regiment1st Brigade (SBCT), 25th Infantry DivisionRest In Peace SSG Julian Melo
ForeverStarlight
ForeverStarlight
You have the wrong number of parens. Always count them, in a situation like this. :)
AzProgrmr
AzProgrmr
You are missing a parenthesis. It should look like so:

r1 = (-b + (sqrt(Squared(b)*(-4*a*c))/(2*a)));
r2 = (-b - (sqrt(Squared(b)*(-4*a*c))/(2*a)));
AzProgrmr
AzProgrmr
Damn. Beat me by 30 seconds.
USArmyMortars
USArmyMortars
heh, thanks. you know, i would be embarrassed or feel stupid at this point, but im at work, and i keep getting distracted. Thanks fellas
HHC 1st Battalion, 5th Infantry Regiment1st Brigade (SBCT), 25th Infantry DivisionRest In Peace SSG Julian Melo
antareus
antareus
I'll try to add something that hasn't been said before. In a situation like this you could always split part of the equation into its own function to help readability and kill a bunch of those parenthesis.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.