Algorithm for To find the roots of the
quadratic equation
Description:
Nature
of roots of quadratic equation can be known from the
quadrant = b2-4ac If b2-4ac >0 then roots
are real and unequal
If b2-4ac
=0 then roots are real and equal If b2-4ac <0 then roots are
imaginary
Algorithm:
Step 1: start
Step
2: read the a,b,c value
Step 3: if b*b-4ac>0 then
Root 1= (-b+ pow((b*b-4*a*c),0.5))/2*a
Root 2= (-b-pow((b*b-4*a*c),0.5))/2*a
Step 4: if b*b-4ac=0 then
Root1 = Root2 = -b/(2*a)
Step
5: Otherwise Print Imaginary roots. Goto step 7.
Step
6: print roots
Step 7: stop
No comments:
Post a Comment