Write Anglorithm That Will Do Following - Ask T...
Write Anglorithm That Will Do Following - Ask T...
Assuming you're asking for algorithms described in a clear, structured English format
(pseudocode), here's how you can approach each of the tasks you described:
Anglorithm: FindQuadraticRoots
1. START
2. DECLARE real variables a, b, c, discriminant, root1, root2, realPart, imaginaryPart
3. DISPLAY "Enter the coefficient 'a':"
4. INPUT a
5. DISPLAY "Enter the coefficient 'b':"
6. INPUT b
7. DISPLAY "Enter the coefficient 'c':"
8. INPUT c
9. IF a is 0 THEN
○ DISPLAY "Error: 'a' cannot be zero for a quadratic equation. This is a linear
equation."
○ IF b is NOT 0 THEN
■ root1 = -c / b
■ DISPLAY "The equation is linear. The root is: ", root1
○ ELSE
■ DISPLAY "Invalid equation. Both 'a' and 'b' are zero."
10.ELSE
○ discriminant = b*b - 4*a*c
○ IF discriminant > 0 THEN
■ root1 = (-b + SQRT(discriminant)) / (2*a)
■ root2 = (-b - SQRT(discriminant)) / (2*a)
■ DISPLAY "The roots are real and distinct:"
■ DISPLAY "Root 1 = ", root1
■ DISPLAY "Root 2 = ", root2
○ ELSE IF discriminant = 0 THEN
■ root1 = -b / (2*a)
■ DISPLAY "The roots are real and equal:"
■ DISPLAY "Root 1 = Root 2 = ", root1
○ ELSE (discriminant < 0)
■ realPart = -b / (2*a)
■ imaginaryPart = SQRT(ABS(discriminant)) / (2*a)
■ DISPLAY "The roots are complex and conjugate:"
■ DISPLAY "Root 1 = ", realPart, " + ", imaginaryPart, "i"
■ DISPLAY "Root 2 = ", realPart, " - ", imaginaryPart, "i"
11. END