expected primary-expression

I am a first time C++ programmer. This simple program is getting an error:
expected primary-expression before ‘=’ token

return = result;

The code follows:

// Solve Quadratic equation
float Quadratic (float A,
float B,
float C)
float Sol1;
float Sol2;
float Disc;
float result;
if (A==0)
result = -B/C;
if (C==0)
result = 0;
Disc = BB - 4 A C;
Sol1 = (-B + sqrt (Disc))/(2
Sol2 = (-B - sqrt (Disc))/(2A);
if (abs (Sol1) < abs (Sol2))
result = Sol1;
result = Sol2;
return = result;
} /
Quadratic */

  return = result; What's that? Ever seen code like that before?

Please remember to post your code in code tags

At first, I had 'return' everywhere that I now have 'result'. I thought perhaps the multiple occurences of 'return' was the problem, so I created a temporary 'result' to hold the value, then set return to that value. Same error occurs, it just appears on the last line instead of on the first time I use "return = ..."

I just don't understand why I get an error setting the return value. Perhaps I made a simple typo or have bad structure. This is part of a larger module and everything else compiles.

I just don’t understand why I get an error setting the return value

you don’t set a return value, you return the return value.

in the reference, return doesn't reuire '='.


Thank you!!!! Its so obvious once you pointed it out. Steep learning curve for me.