Mar 21, 2014 at 2:38pm
it's not giving the correct results |
It doesn't even compile on my box.
e.g. you're telling calculate to return a double, but your function does not return anything.
leaving that aside though...
1 2 3
|
double a, b, c, d, x;
x = (b * b) - (4 * a * c);
|
what do you think x will be calculated to, considering you haven't initialised a, b or c..?
remove the declarions for a,b and c in this function, and have them be passed in.
Last edited on Mar 21, 2014 at 2:45pm
Mar 21, 2014 at 2:52pm
You haven't passed any values to the calculate function, you need to pass the values you got by reference to calculate such as,
calculate(a,b,c);
Also when you say,
if(d < 0){
Well you should be saying,
if (x < 0)
as you have already taken sqrt of x.
Mar 21, 2014 at 4:47pm
Thanks guys for the assistance. I've managed to fix the issues you pointed out and it's now working.