if D > 0 then begin x1 := (-b + sqrt(D)) / (2a); x2 := (-b - sqrt(D)) / (2a); writeln('The roots are real and different: x1 = ', x1:0:2, ' and x2 = ', x2:0:2); end else if D = 0 then begin x1 := -b / (2a); writeln('The roots are real and equal: x = ', x1:0:2); end else begin writeln('The roots are complex and different: x1 = ', -b/(2a):0:2, ' + ', sqrt(-D)/(2a):0:2, 'i and x2 = ', -b/(2a):0:2, ' - ', sqrt(-D)/(2*a):0:2, 'i'); end; end.
program QuadraticEquationSolver;
var a, b, c, D, x1, x2: real;
begin
write('Enter the value of a: ');
readln(a);
write('Enter the value of b: ');
readln(b);
write('Enter the value of c: ');
readln(c);
D := bb - 4a*c;
if D > 0 then
begin
x1 := (-b + sqrt(D)) / (2a);
x2 := (-b - sqrt(D)) / (2a);
writeln('The roots are real and different: x1 = ', x1:0:2, ' and x2 = ', x2:0:2);
end
else if D = 0 then
begin
x1 := -b / (2a);
writeln('The roots are real and equal: x = ', x1:0:2);
end
else
begin
writeln('The roots are complex and different: x1 = ', -b/(2a):0:2, ' + ', sqrt(-D)/(2a):0:2, 'i and x2 = ', -b/(2a):0:2, ' - ', sqrt(-D)/(2*a):0:2, 'i');
end;
end.