Want more features on Pastebin? Sign Up, it's FREE!

Contoh Program Pascal (Mencari Akar Persamaan Kuadrat)

By: Polma on Nov 2nd, 2013  |  syntax: Pascal  |  size: 0.89 KB  |  views: 78  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Program Persamaan_Kuadrat;
  2. Uses crt;
  3.  
  4. label menu;
  5. Var A,B,C:integer;
  6. D,X1,X2:real;
  7. ab:char;
  8.  
  9. Begin
  10.  menu:
  11.  clrscr;
  12.  writeln('Polma Saut Martua Sihotang');
  13.  writeln('118130023 / IK-37-01');
  14.  writeln('==========================');
  15.  writeln;
  16.  writeln ('Ax2 + Bx + C = 0');
  17.  writeln;
  18.  Write('Masukkan Nilai A: ');readln(A);
  19.  Write('Masukkan Nilai B: ');readln(B);
  20.  Write('Masukkan Nilai C: ');readln(C);
  21.  writeln;
  22.  
  23.  D:=sqr(B)-(4*A*C);
  24.  if (D>0) then
  25.   begin
  26.    X1:=(-B+sqrt(D))/2*A;
  27.    X2:=(-B-sqrt(D))/2*A;
  28.    writeln('X1= ',X1:4:1);
  29.    writeln('X2= ',X2:4:1);
  30.   end
  31.  else
  32.  if (D=0) then
  33.   begin
  34.    X1:=-B/(2*A);
  35.    writeln('X1=X2=',X1:4:1);
  36.   end
  37.  else
  38.   writeln('Akar Imajiner!');
  39.   writeln('Apakah anda ingin mengulang ? (Y/N) : '); readln(ab);
  40.   if (ab='y') or (ab='Y') then goto menu
  41.   else if (ab='n') or (ab='N') then
  42.    begin
  43.     exit;
  44.    end;
  45. readln;
  46. End.
clone this paste RAW Paste Data