ok i made a program which works out x from a quadratic formula when you enter values for a, b and c (which are "real" numbers) it puts the numbers in an equation but it does not work! it compiles fine.. but when i try using the program it says ERROR 207: invalid floating point operation
This is the line of code that it points too
x:=-b+sqrt(((b*b)-(4*a*c))/2*a);
i think its got something to do with all the operations happening in one line.. do you think this is a problem? also is there supposed to be any statement under "uses" (eg uses crt;)so i can use the sqrt operation?
Thanks in advance!
Comments
Usually the best thing to do in these situations is to debug the program.
And the quadratic formula should be:
x:=(-b+sqrt((b*b)-(4*a*c)))/2*a;
instead of:
x:=-b+sqrt(((b*b)-(4*a*c))/2*a);
var x1,x2,a,b,c:real;
if b*b-4*a*c>0 then
begin
x1:=(-b-sqrt(b*b-4*a*c))/(2*a);
x2:=(-b+sqrt(b*b-4*a*c))/(2*a);
end;