Beranda > Algoritma Pemrograman, Pemrograman Pascal > Program Basic pada Pascal

Program Basic pada Pascal


Berikut beberapa contoh program basic dengan bahasa Pascal yang dapat dicompiler dengan Borland Delphi, Lazarus ataupun aplikasi compiler Pascal lainnya.
1. Program Increment Angka

program angkanaik;

{$APPTYPE CONSOLE}

uses
SysUtils;

var i,j:integer;
begin
i:=1;

while i<=5 do
begin
j:=1;
while j<=i do
begin
write(‘ ‘,j);
j:=j+1;

end;

i:=i+1;
writeln(‘ ‘);
end;
readln;
end.

=================================================================================
2. Program Decrement Angka


program angkamenurun;

{$APPTYPE CONSOLE}

uses
SysUtils;

var i,j:integer;
begin
i:=5;

while i>=1 do
begin
j:=1;
while j<=i do
begin
write(‘ ‘,j);
j:=j+1;

end;

i:=i-1;
writeln(‘ ‘);
end;
readln;
end.

=================================================================================
3. Program Dec-Inc Angka


program angkaturunnaik;

{$APPTYPE CONSOLE}

uses
SysUtils;

var a,b,i,j:integer;

begin
a:=10;
while a>=1 do
begin
b:=1;
while b<=a do
begin
write (‘ ‘,b);
b:=b+1;
end;
a:=a-1;
writeln(‘ ‘);

end;

i:=1;
while i<=10 do
begin
j:=1;
while j<=i do
begin
write (‘ ‘,j);
j:=j+1;
end;
i:=i+1;
writeln(‘ ‘);

end;
readln;
end.

================================================================================
4. Program Inc-Dec Angka


program angkanaikturun;

{$APPTYPE CONSOLE}

uses
SysUtils;

var i,j,a,b:integer;
begin
i:=1;
while i<=10 do
begin
j:=1;
while j<=i do begin write (‘ ‘,j); j:=j+1; end; i:=i+1; writeln(‘ ‘); end; a:=10; while a>=1 do
begin
b:=1;
while b<=a do
begin
write (‘ ‘,b);
b:=b+1;
end;
a:=a-1;
writeln(‘ ‘);
end;
readln;
end.

=================================================================================
5. Program Input Angka yang akan Di-Decrementkan

program masukangkanaik;

{$APPTYPE CONSOLE}

uses
SysUtils;

var x,i,j:integer;
begin
write (‘Masukkan nilai 1-10: ‘);
readln (x);
i:=1;
while (i<=x) and (x<=10) do
begin
j:=1;
while j<=i do
begin
write (‘ ‘,i);
j:=j+1;
end;
i:=i+1;
writeln;
end;
readln;
end.

=================================================================================
6. Program Mencari Akar dan Pangkat dari Bilangan

program akarpangkat;

{$APPTYPE CONSOLE}

uses
SysUtils;

var x,y,i,n:integer;
begin
write (‘Masukkan nilai: ‘);
readln (x);
writeln(‘Akar dari ‘,x,’ adalah ‘,SQRT(x):4:2);
readln;
//cari pangkat m dari bilangan n
i:=1;
n:=1;
write (‘Masukkan nilai: ‘);
readln (x);
write (‘Masukkan pangkat: ‘);
readln (y);
while i<=y do
begin
n:=n*x;
i:=i+1;
end;
write (x,’ pangkat ‘,y,’ = ‘,n);
readln;
end.

=================================================================================
7. Program Bilangan Ganjil-Genap


program repeatuntil;

{$APPTYPE CONSOLE}

uses
SysUtils;

var
x:integer;
lagi:char; //tipe data karakter
begin
repeat
write(‘Masukkan bilangan ‘);readln(x);
if x mod 2=0 then
begin
writeln(x,’ adalah bilangan Genap’);
end
else
begin
writeln(x,’ adalah bilangan Ganjil’);
end;
writeln(”);
write(‘Mau masukkan data lagi? (y/n) ‘);
readln(lagi);
until(lagi<>’y’) ;
end.

Download filenya di sini.

  1. Dewii
    November 1, 2010 pukul 8:55 pm

    thx bwd codingnya K…smuga membantuku pass mid..wkwk

    • nayay18
      November 2, 2010 pukul 5:10 am

      sm2…good luck for MID nya😀

  2. Dewii
    November 3, 2010 pukul 2:44 am

    Huuhft. .brhasil C brhasil tp MOODnya pDosen agy error..imbasx ke pROgram pwa..>,<

    • nayay18
      November 4, 2010 pukul 4:32 am

      *z edit komenmu nh, dilarang mnyebutkan lgsg nm dosen di dunia maya :p*

      hmm..bgtu mi seninya jd mhs d’…klo katanya RSW ttp dlm perdjoeangan

  3. ihona
    November 4, 2010 pukul 8:53 pm

    *weittzz..dilarang mngedit komen org tanpa seizin yg punyaa…wkwkw*

    lgian nama samaran ji jg K…^__^

    bdw jadul mode:on pwa..ahhaaha

    • nayay18
      November 5, 2010 pukul 5:50 am

      kloningnya dewii lg…apanya yg jadul? *lalo mode:ON

  4. Dewii
    November 4, 2010 pukul 9:00 pm

    *weittzz..dilarang mngedit komen org tanpa seizin yg punyaa…wkwkw*
    lgian nama samaran ji jg K…^__^
    bdw jadul mode:on pwa..ahhaaha

  5. Dewii
    November 5, 2010 pukul 7:09 am

    Wkwk. . .plangGran hak cipta. . .

  6. Juli 25, 2011 pukul 5:55 am

    makasih banyak yah contoh pascalnya, sangat membantu sekali!!!

    salam.

    • nayay18
      Juli 25, 2011 pukul 7:12 pm

      sama2…😀

  7. Nia
    April 21, 2012 pukul 10:53 pm

    🙂 ini untuk informatika ya???🙂 pascal masuk dalam smester brapa nihh?? hooho… Thanks yaaa ini berguna banget lhooo🙂

    • nayay18
      Desember 21, 2012 pukul 7:46 pm

      hmm iya, kebetulan saya jg kuliah di informatika, waktu itu semester 3 kalo tdk salah..

      sama2..senang bisa membantu😀

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: