Jumat, 19 April 2013
Posts by : Admin
Program Pascal untuk Mencari Akar Persamaan Kuadrat
Program persamaan_kuadrat;
Uses wincrt;
var
a,b,c,D,x1,x2:real;
begin
writeln('Program Persamaan Kuadrat');
write('Ketikkan nilai a: ');readln(a);
write('Ketikkan nilai b: ');readln(b);
write('Ketikkan nilai c: ');readln(c);
D:=(b*b)-(4*a*c);
writeln('D=',D:5:2);
if D<0 then
begin
writeln('D<0');
writeln('x1 dan x2 tidak real atau imajiner');
end
else if D=0 then
begin
writeln('D=0');
writeln('x1 dan x2 real dan sama');
x1:=(-b+(sqrt(D)))/(2*a);
x2:=(-b-(sqrt(D)))/(2*a);
writeln('x1=',x1:5:2);
writeln('x2=',x2:5:2);
end
else if D>0 then
begin
writeln('D>0');
writeln('x1 dan x2 real dan berlainan');
x1:=(-b+(sqrt(D)))/(2*a);
x2:=(-b-(sqrt(D)))/(2*a);
writeln('x1=',x1:5:2);
writeln('x2=',x2:5:2);
end;
end.
Langganan:
Posting Komentar (Atom)
You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "
4 komentar:
jika USES wincrt nya gak bisa...
bisa diubah ke USES crt nya gak
mantap kali bu
makasih mbak
sangat membantu,,makasih
Posting Komentar