Algorithm of Quadratic Equation

By | November 18, 2012

Quadratic-Equation
Example 4: Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation ax2 + bx + c= 0
Hint: d= sqrt (b2 – 4ac), and the roots are:  x1= (–b + d)/2a   and x2= (–bd)/2a

Pseudocode:

Input the coefficients (a, b, c) of the quadratic equation 
Calculate the discriminant d
Calculate x1 
Calculate the discriminant d

Calculate  x1

Calculate x2
Print x1and x2

Algorithm:

Step 1:            Input a, b, c

Step 2:            d = sqrt (b2 – 4 x a x c
Step 3:            x1= (–b + d) / (2 x a)
Step 4:            x2 = (–bd) / (2 x a)
Step 5:            Print x1 and x2

Flowchart:

Flowchart

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS