Example 1. State The Problem: Input
Example 1. State The Problem: Input
Example 1. State The Problem: Input
1 2
The output from the program will be the real roots We will now break each of the above major
of the quadratic equation, whether they are distinct sections into smaller, more detailed pieces.
real roots, or repeated real roots.
3 4
4. Pseudocode 4. Pseudocode
Prompt the user for the coefficients a, b, and c. IF discriminant < 0 THEN
Read a, b, and c Write message that equation has no real roots.
Echo the input coefficients ELSE IF discriminant > 0 THEN
discriminant ← b**2 - 4. * a * c x1 ← (-b + sqrt(discriminant)) / (2. * a )
x2 ← (-b - sqrt(discriminant)) / (2. * a )
Write message that equation has two distinct real
roots.
Write out the two roots
5 6
4. Pseudocode
ELSE
x1 ←-b / (2. * a)
Write message that equation has two identical
real roots.
Write out the repeated root.
END IF