- Chương trình giải phương trình bậc 2 :
uses crt;
var a, b, c, dt : real;
begin
clrscr;
write('Nhap he so a, b, c : '); readln(a, b, c);
dt := b * b - 4 * a * c;
if dt > 0 then begin
writeln('x1 = ', (-b + sqrt(dt)) / (2 * a) : 2 : 2);
writeln('x2 = ', (-b - sqrt(dt)) / (2 * a) : 2 : 2);
end else if dt = 0 then
writeln('x = ', -b / (2 * a) : 2 : 2)
else writeln('Vo nghiem');
readln
end.
- Chương trình giải ax + b = 0
uses crt;
var a, b : integer;
begin
clrscr;
write('Nhap hai so a, b = '); readln(a, b);
if (a = 0) and (b = 0) then write('Vô số nghiệm');
if (a = 0) and (b <> 0) then write('Vô nghiệm');
if a <> 0 then write('x = ', -b / a : 2 : 2);
readln
end.