program mencari akar persamaan kuadrat

program mencari_akar_persamaan_kuadrat;
uses wincrt;

var
x1,x2:real;
a,b,c,d:integer;

begin
writeln('PROGRAM MENCARI AKAR PERSAMAAN KUADRAT ax^2+bx+c=0');
write('diketahui nilai a =');read(a);
write('diketahui nilai b =');read(b);
write('diketahui nilai c =');read(c);

d:=b*b-4*a*c;
if d<0 then writeln('tidak ada hasil akar real')
else
begin
x1:=(-b+(sqrt(d)))/2*a;
x2:=(-b-(sqrt(d)))/2*a;
writeln('x1= ',x1:4:2);
writeln('x2= ',x2:4:2);
end;

readln;
end.

Categories:

0 comments:

Post a Comment