Roots of a quadratic function: Difference between revisions
m
→{{header|Icon}} and {{header|Unicon}}: was wrong
mNo edit summary |
m (→{{header|Icon}} and {{header|Unicon}}: was wrong) |
||
Line 816:
procedure solve(a,b,c)
d := sqrt(b*b - 4.0*a*c)
roots := if b < 0 then [r1 := (-b+d)/(2.0*a), c/(a*r1)]
else [r1 := (-b-d)/(2.0*a), c/(a*r1)]
write(a,"*x^2 + ",b,"*x + ",c," has roots ",roots[1]," and ",roots[2])
end</lang>
|