Roots of Quadratic Equation

Roots of Quadratic Equation :

This program calculates the roots of a quadratic equation using QUADRATIC FORMULA.

ALGORITHM:

    1. Input the coefficents of x,x^2and const as b,a,c.
    2. Calulate discriminant, D=b^2-4ac.
    3. CHECK
        • if D=0
          SET x1=-b/2a
          PRINT roots are equal and print roots as x1.CHECK
        • if D<0
          SET x1=-b/2a and x2=sqrt(-1*D)/2a
          PRINT roots are complex and print roots as x1+ix2 and x1-ix2.
        • if D>0
          SET x1=(-b+sqrt(D))/2a
          SET x1=(-b-sqrt(D))/2a
          PRINT distinct roots and them as x1 and x2

C SOURCE CODE:

Leave a Reply

Your email address will not be published. Required fields are marked *