You misplaced a bracket by the way, it should be this:
qans2 = (-b - sqrt( pow(b,2) - (4 * (a * c)))) / (2 * a);
With what you posted above, it would've just taken the square root of b squared. You wanted the square root of "b squared minus 4 a c".
---
The error you're getting means that it doesn't know how to treat the parameter to the "sqrt" function. The parameter, namely,
pow(b,2) - (4 * (a * c)) can be treated as type
long double OR type
float OR type
double. The compiler can't handle the ambiguity. It needs
you to tell it how to treat the parameter.
Forcing an expression to be a certain type is called
type casting.
e.g.
1 2 3 4 5
|
int main()
{
float answer = ((float)5)/2;
return 0;
}
|
On line 3, the literal 5 is being
type cast as a
float (it would've been treated as an
int otherwise).
In your case, since ans1 and ans2 are both floats, you should
type cast the expression "pow(b,2) - (4 * (a * c))" as a
float for both calls to sqrt. I have given an example above (and in my previous post) on how to do this.