begin writeln('Enter the coefficients of the quadratic equation ax^2 + bx + c = 0:'); write('Enter a: '); readln(a); write('Enter b: '); readln(b); write('Enter c: '); readln(c);
D := b b - 4 a * c;
if D > 0 then begin x1 := (-b + sqrt(D)) / (2 a); x2 := (-b - sqrt(D)) / (2 a); writeln('The quadratic equation has two real roots:'); writeln('x1 = ', x1:0:2); writeln('x2 = ', x2:0:2); end else if D = 0 then begin x1 := -b / (2 * a); writeln('The quadratic equation has one real root:'); writeln('x1 = x2 = ', x1:0:2); end else begin writeln('The quadratic equation has two imaginary roots.'); end; end.
program QuadraticEquation;
var
a, b, c, D, x1, x2: real;
begin
writeln('Enter the coefficients of the quadratic equation ax^2 + bx + c = 0:');
write('Enter a: ');
readln(a);
write('Enter b: ');
readln(b);
write('Enter c: ');
readln(c);
D := b b - 4 a * c;
if D > 0 then
begin
x1 := (-b + sqrt(D)) / (2 a);
x2 := (-b - sqrt(D)) / (2 a);
writeln('The quadratic equation has two real roots:');
writeln('x1 = ', x1:0:2);
writeln('x2 = ', x2:0:2);
end
else if D = 0 then
begin
x1 := -b / (2 * a);
writeln('The quadratic equation has one real root:');
writeln('x1 = x2 = ', x1:0:2);
end
else
begin
writeln('The quadratic equation has two imaginary roots.');
end;
end.