Program Persamaan_Kuadrat;
Uses Wincrt;
label ulang;
Var A,B,C:integer;
D,X1,X2:real;
ab:char;
Begin
ulang:
clrscr;
Writeln('Program Persamaan Kuadrat');
Writeln('=========================');
Writeln;
Write('Masukkan Nilai A: ');readln(A);
Write('Masukkan Nilai B: ');readln(B);
Write('Masukkan Nilai C: ');readln(C);
Writeln;
D:=sqr(B)-(4*A*C);
if (D>0) then
begin
X1:=(-B+sqrt(D))/2*A;
X2:=(-B-sqrt(D))/2*A;
Writeln('X1= ',X1:4:1);
writeln('X2= ',X2:4:1);
end
else if (D=0) then
begin
X1:=-B/(2*A);
Writeln('X1=X2=',X1:4:1);
end
else
Writeln('Bukan Akar Real!');
writeln('Apakah anda ingin mengulanginya (y/t): ');
readln(ab);
if (ab='y') or (ab='Y') then
begin
goto ulang;
end
else
donewincrt;
readln
End.
Program Persamaan Kuadrat
Categories:
program bahasa pascal
0 comments:
Post a Comment