CLS
start:
' data input
PRINT "Give the coefficients A, B, C: "
INPUT a, b, c
' linear equation
IF a = 0 THEN
IF NOT (b = 0) THEN
PRINT "Single root: ", -c / b
GOTO check
ELSE
IF c = 0 THEN
PRINT "All real numbers are roots."
GOTO check
ELSE
PRINT "No roots."
GOTO check
END IF
END IF
END IF
' quadratic equation
d = b ^ 2 - 4 * a * c
IF d < 0 THEN
PRINT "No roots (discriminant ="; d; ")"
GOTO check
END IF
IF d = 0 THEN
PRINT "One double root: "; -b / (2 * a)
GOTO check
END IF
' Here the discriminant is positive
r1 = (-b + SQR(d)) / (2 * a)
r2 = (-b - SQR(d)) / (2 * a)
PRINT "Two roots: "; r1; " and "; r2
check:
PRINT "Give 1 to continue, 0 to stop: "
INPUT ans
IF ans = 1 THEN
GOTO start
END IF