text maarque kanan

INGATKAN DIRIMU UNTUK MENGATUR SEGALA SESUATU SUDAH DI ATUR ALLOH

salju

Rabu, 04 Juli 2012

Pascal 100


1.
Program Dasar;
Uses WinCrt;
begin
end.
2.
Program Dasar;
Uses WinCrt;
begin
     writeln('Khoirul Arifin');
     writeln('--------------');
end.
3.
Program Contoh_Konstanta(Layar);
Uses WinCrt;
const
     potongan       = 0.2;
     gaji           = 60000;
     NamaPerusahaan = 'P.T Multi Sarana Tekhnik';
begin
     Writeln('Potongan = ',Potongan);
     Writeln('Gaji     = ',Gaji);
     Writeln('Nmam     = ',NamaPerusahaan);
  
end.
4.
Program Contoh_Konstanta_Terdefinisi(Layar);
Uses WinCrt;

begin
     Writeln('Nilai Logika Benar = ',True);
     Writeln('Nilai Logika Salah = ',False);
     Writeln('Nilai Maxint       = ',Maxint);
     Writeln('Nilai MaxLongint   = ',MaxLongint);
  
end.
5.
Program Contoh_Konstanta_Terdefinisi(Layar);
Uses WinCrt;
Var
   Total, Gaji, Tunjangan : Real;
   Menikah                : Boolean;
   JumlahAnak             : Integer;
   Keterangan             : String[25];

begin
     Gaji       := 60000;
     Menikah    := True;
     JumlahAnak := 3;
     Tunjangan  := 0.25 * Gaji + JumlahAnak * 30000.0;
     Total      := Gaji + Tunjangan;
     Keterangan := 'Karyawan Teladan';
     Writeln('Gaji Bulanan   : Rp',Gaji);
     Writeln('Tunjangan      : Rp',Tunjangan);
     Writeln('Total Gaji     : Rp',Total);
     Writeln('Sudah Menikah  : ',Menikah);
     Writeln('Jumlah Anak    : ',JumlahAnak);
     Writeln('Keterangan     :',Keterangan);
  
end.
6.
Program Contoh_Tipe_Data_Terdefinisi(Layar);
Uses WinCrt;
Type
    Pecahan     = Real;
    Logika      = Boolean;
    Bulat       = Integer;
    Huruf       = String[25];
Var
   Total, Gaji, Tunjangan : Real;
   Menikah                : Boolean;
   JumlahAnak             : Integer;
   Keterangan             : Huruf;

begin
     Gaji       := 60000;
     Menikah    := True;
     JumlahAnak := 3;
     Tunjangan  := 0.25 * Gaji + JumlahAnak * 30000.0;
     Total      := Gaji + Tunjangan;
     Keterangan := 'Karyawan Teladan';
     Writeln('Gaji Bulanan   : Rp',Gaji);
     Writeln('Tunjangan      : Rp',Tunjangan);
     Writeln('Total Gaji     : Rp',Total);
     Writeln('Sudah Menikah  : ',Menikah);
     Writeln('Jumlah Anak    : ',JumlahAnak);
     Writeln('Keterangan     :',Keterangan);
  
end.
7.
Program Contoh_Label(Layar);
Uses WinCrt;
Label
     100, Selesai;
Begin
     Writeln('Khoirul');
     Goto 100;
     Writeln('Misbach');
     Writeln('Putro');
100:
    Writeln('Arifin');
    Goto Selesai;
    Writeln('Banjari');
Selesai:
end.
8.
Program Contoh_Procedure(Layar);
Uses WinCrt;
Procedure Tambah(x,y : Integer;Var Hasil : Integer);
Begin
     Hasil := x + y;
end;
Var
   z : Integer;
Begin
     Tambah(2,3,z);
     Writeln('2+3= ',z);
end.
9.
Program Contoh_Fungsi(Layar);
Uses WinCrt;
Function
        Tambah(x,y : Integer) : Integer;
Begin
     Tambah := x+y;
end;
Begin
     Writeln('2+3= ',Tambah(2,3));
end.
10.
Program Hapus_Layar;
Uses WinCrt;
Begin
     ClrScr;
     Writeln('Khoirul Arifin');
     Writeln('--------------');
end.
11.
Program Penjumlahan_Langsung;
Uses WinCrt;
Var
   a,b,c : Integer;
Begin
     ClrScr;
     a :=2;
     b :=3;
     c :=a+b;
     Writeln('c = ',c);
end.
12.
Program Tipe_Data_Integer;
Uses WinCrt;
Var
   Jumlah : byte;
Begin
     Jumlah := 200;
     Writeln('Nilai JUMLAH = ',Jumlah);
end.
__________________________________________________________________________________13.
Program Tipe_Data_Numerik_Real;
Uses WinCrt;
Var
   Nilai1, Nilai2 : Real;
Begin
     Nilai1 := 12345678901.2345;
     Nilai2 := 12345;
     Writeln('Nilai1 = ',Nilai1);
     Writeln('Nilai2 = ',Nilai2);
end.
14.
ProGram Tipe_Data_Karakter;
Uses WinCrt;
Var
   SebuahKarakter : Char;
Begin
     SebuahKarakter := 'A';
     Writeln('Karakter tersebut = ',SebuahKarakter);
end.
__________________________________________________________________________________15.
Program Tipe_Data_String;
Uses WinCrt;
Var
   Tanggal      : String[10];
   Hari         : String[7];
   Pasaran      : String[6];
   Jarak        : Char;
Begin
     Tanggal    := '26-02-2012';
     Hari       := 'Minggu';
     Pasaran    := 'Kliwon';
     Jarak      := ' ';
     Writeln(Tanggal,Jarak,Hari,' ',Pasaran);
end.
16.
Program Data_Boolean;
Uses WinCrt;
Var
   Lagi : Boolean;
Begin
     Lagi := True;
     Writeln('Nilai Lagi = ',Lagi);
End.
17.
Program Karakter_Kontrol;
Uses WinCrt;
Begin
     Writeln(#75#72#79#73#82#85#76#32#65#82#73#70#73#78);
End.
18.
Program Kontrol_Karakter;
Uses WinCrt;
Var
   GantiBaris : Char;
Begin
     GantiBaris := #10;
     Writeln('Baris Pertama',GantiBaris,GantiBaris,#13,'Baris Ketiga');
End.
19.
Program Karakter_Kontrol;
Uses WinCrt;
Begin
     Writeln('Apakah Anda Mendengar Bunyi Bel 2 Kali ? ',^g#7)
End.
20.
Program Binary_Operator;
Uses WinCrt;
Begin
     Writeln(15*5);
     Writeln(20/3);
     Writeln(20 div 3);
     Writeln(20 mod 3);
End.
21.
Program Unary_Operator;
Uses WinCrt;
Begin
     Writeln(5+(-15));
End.
22.
Program Bitwise_Operator_Not;
Uses WinCrt;
Begin
     Writeln(not 0);
     Writeln(not 5);
     Writeln(not 18);
     Writeln(not -17);
End.
23.
Program Bitwise_and;
Uses WinCrt;
Begin
     Writeln(12 And 23);
End.
24.
Program Bitwise_or;
Uses WinCrt;
Begin
     Writeln(12 or 23);
End.
25.
Program Bitwise_xor;
Uses WinCrt;
Begin
     Writeln(12 xor 23);
End.
__________________________________________________________________________________26.
Program Bitwise_Shl;
Uses WinCrt;
begin
     Writeln(5 shl 6);
End.
27.
Program Bitwise_Shr;
Uses WinCrt;
Begin
     Writeln(160 Shr 6);
End.
28.
Program Relational_Operator;
Uses WinCrt;
Var
   a,b : Integer;
Begin
     a := 5;
     b := 3;
     Writeln(a=b);
     Writeln(a=5);
     Writeln(a<>b);
     Writeln(a>b);
     writeln(a>=b);
     Writeln(a<b);
     Writeln(a<=b);
End.
29.
Program Logical_Operator;
Uses WinCrt;
Begin
     Writeln(not True);
     Writeln(not False);
     Writeln(True And False);
     Writeln(True Or False);
     Writeln(True Xor False);
End.
30.
Program Address_Operator;
Uses WinCrt;
Type
    TipeString          = String[40];
    PointerString       = ^TipeString;
Var
   Nama         : TipeString;
   LetakNama    : PointerString;
Begin
     Nama       := 'Khoirul Arifin';
     LetakNama  := @Nama;
     Writeln('Nama Adalah      : ',Nama);
     Writeln('Nama Adalah      : ',LetakNama^);
End.
31.
Program STring_Operator;
Uses WinCrt;
Var
   Nama1, Nama2, Nama3 : String[15];
Begin
     Nama1  := 'Khoirul ';
     Nama2  := 'Arifin';
     Nama3  := Nama1 + Nama2;
     Writeln(Nama3)
End.
32.
Program Komentar;
Uses WinCrt;
Begin
     Writeln('Halo apa kabar ? ');
     Writeln('Program saya ini di beri komentar lho ..');
End.
33.
Program Statement_jamak;
Uses Wincrt;
Var
   Nilai                : Real;
   Keterangan, Komentar : String[25];
Begin
     Nilai      := 55.5;
     Keterangan := 'Tidak lulus';
     Komentar   := 'Mengecewakan';
     If Nilai > 60 Then
        Keterangan := 'Lulus';
        Komentar   := 'Memuaskan';
     Writeln('Keterangan : ',Keterangan);
     Writeln('Komentar   : ',Komentar);
End.
34.
Program Input1_data_keVariabel;
Uses WinCrt;
Var
   a, b : Integer;
   c    : Real;
   d    : String[10];
   e    :Char;
Begin
     Readln(a);
     Readln(b);
     Readln(c);
     Readln(d);
     Readln(e);
     Writeln;
     Writeln('a = ',a);
     Writeln('b = ',b);
     Writeln('c = ',c);
     Writeln('d = ',d);
     Writeln('e = ',e);
End.
35.
Program Input2_Konversi_celcius_fahrenheit;
Uses WinCrt;
Var
   c, f : Real;
Begin
     Write('Berapa Celcius ? ');
     Readln(c);
     F := 1.8 * c + 32;
     Writeln;
     Writeln(c,' Celcius adalah ',F,' Fahrenheit');
End.
36.
Program Input5(Input,Output);
Uses WinCrt;
Var
   Jawab_c : Char;
   Jawab_b : boolean;
Begin
     Write('Benar atau salah (B/S) ? ');
     Readln(Jawab_c);
     Jawab_b := (Jawab_c = 'b');
     Writeln('Yang anda maksud adalah : ',Jawab_b);
End.
37.
Program Tampil1(output);
Uses WinCrt;
Var
   Nama : String[15];
Begin
     Nama := 'Khoirul Arifin';
     Write('Nama : ');
     Write(Nama);
End.
38.
Program Tampil2(output);
Uses WinCrt;
Var
   Nama : String[15];
Begin
     Nama := 'Khoirul Arifin';
     Writeln('Nama : ');
     Writeln(Nama);
End.
39.
Program Tampil3(output);
Uses WinCrt;
Var
   Bulat1, Bulat2 : Integer;
Begin
     Bulat1     := 123;
     Bulat2     := 12345;
     Writeln(Bulat1, Bulat2);
End.
40.
Program Tampil5(output);
Uses WinCrt;
var
   Huruf1, Huruf2 : Char;
Begin
     Huruf1 :='a';
     Huruf2 :='b';
     Writeln(Huruf1,Huruf2);
End.
41.
Program Tampil6(output);
Uses WinCrt;
Var
   String1, String2 : String[10];
Begin
     String1 := 'Khoirul';
     String2 := ' Arifin';
     Writeln(String1,String2);
End.
42.
Program Tampil7(output);
Uses WinCrt;
Var
   Logika1, Logika2 : Boolean;
Begin
     Logika1 := True;
     Logika2 := False;
     Writeln(Logika1,Logika2);
End.
43.
Program Tampil8(output);
Uses WinCrt;
Var
   Ket1, Ket2 : Char;
Begin
     Ket1 := 'a';
     ket2 := 'b';
     Writeln(ket1:5,Ket2:10);
End.
44.
Program Tampil9(output);
Uses WinCrt;
Var
   Karakter : String[14];
Begin
     Karakter := 'Khoirul Arifin';
     Writeln('Nama : ',Karakter : 10);
End.
45.
Program Tampil10(output);
Uses WinCrt;
Var
   n : Integer;
Begin
     n := 275;
     Writeln('Jumlah Data = ',n:5);
End.
46.
Program Tampil11(output);
Uses WinCrt;
Var
   Nilai : Real;
Begin
     Nilai := 123.45;
     Writeln('Nilai Real = ',Nilai:12);
End.
47.
Program Tampil12(output);
Uses WinCrt;
Var
   Nilai : real;
Begin
     Nilai := 123.45;
     Writeln('Nilai Real = ',Nilai:12:3)
End.
48.
Program Tampil13(Output);
Uses WinCrt;
Var
   Nilai : Boolean;
Begin
     Nilai := True;
     Writeln('Nilai Boolean = ',Nilai:6);
End.
49.
Program Tampil14(output);
Uses WinCrt;
Begin
     ClrScr;
     Writeln('Khoirul Arifin');
End.
50.
Program Tampil15(output);
Uses WinCrt;
Begin
     ClrScr;
     Gotoxy(10,15);
     Writeln('Khoirul Arifin');
End.
_________________________________________________________________________________
51.
Program Tampil16(output);
Uses WinCrt;
Var
   Nilai : Integer;
Begin
     ClrScr;
     Gotoxy(10,15);
     Write('Masukkan Sebuah Nilai Integer ? ');
     Readln(Nilai);
     Gotoxy(10,15);
     ClrEol;
     Writeln('Anda Pintar !!');
End.
52.
Program Tampil17(Output);
Uses WinCrt;
Var
   Tekan : Char;
Begin
     ClrScr;
     Gotoxy(5,8);Writeln('Satu');
     Gotoxy(6,9);Writeln('Dua');
     Gotoxy(7,10);Writeln('Tiga');
     Gotoxy(8,11);Writeln('Empat');
     Gotoxy(9,12);Writeln('Lima');
     Gotoxy(10,13);Writeln('Enam');
     Gotoxy(11,14);Writeln('Tujuh');
     Gotoxy(12,15);Writeln('Delapan');
     Gotoxy(13,16);writeln('Sembilan');
     Gotoxy(14,17);Writeln('Sepuluh');
     Gotoxy(15,20);Write('Tekan Sembarang Tombol !!! ');
     Read(tekan);
     Gotoxy(20,20);
     ClrEol;
     Gotoxy(5,9);
    
End.
53.
Program Tampil18(Output);
Uses WinCrt;
Procedure Delline;
begin
     Writeln('    ');
end;
Var
   Tekan : Char;
Begin
     ClrScr;
     Gotoxy(5,8);Writeln('Satu');
     Gotoxy(5,9);Writeln('Dua');
     Gotoxy(5,10);Writeln('Tiga');
     Gotoxy(5,11);Writeln('Empat');
     Gotoxy(5,12);Writeln('Lima');
     Gotoxy(5,20);Write('Tekan Sembarang Tombol !!! ');Read(tekan);
     Gotoxy(5,20);ClrEol;
     gotoxy(5,9);DelLine;
End.
54.
Program Tampil19(Output);
Uses WinCrt;
Procedure InsLine;
begin
     gotoxy(5,10);Writeln('      ');
end;
Var
   Tekan : Char;
Begin
     ClrScr;
     Gotoxy(5,8);Writeln('Satu');
     Gotoxy(5,9);Writeln('Dua');
     Gotoxy(5,10);Writeln('Tiga');
     Gotoxy(5,11);Writeln('Empat');
     Gotoxy(5,12);Writeln('Lima');
     Gotoxy(5,20);Write('Tekan Sembarang Tombol !!! ');Readln(tekan);
     Gotoxy(5,20);ClrEol;
     gotoxy(5,10);InsLine;
End.
55.
Program Perulangan_Positip;
Uses WinCrt;
Var
   I : Integer;
Begin
     For i:= 1 to 5 do
     Begin
          writeln('Khoirul Arifin');
     End;
End.
56.
Program Perulangan_Positip_Dua_Statemen;
Uses WinCrt;
Var
   I : Integer;
Begin
     For i:= 1 to 5 do
     Begin
          Write(i);
          writeln('. Khoirul Arifin');
     End;
End.
57.
Program Perulangan_Positip_Dua_Statemen_Masuk_Tidak;
Uses WinCrt;
Var
   I : Integer;
Begin
     For i:= 1 to 5 do
          Write(i);
     writeln('. Khoirul Arifin');
End.
58.
Program Perulangan_Mengunakan_Tabel;
Uses WinCrt;
Var
   x,x2,x3 : Integer;
   Seperx  : Real;
Begin
     Writeln('---------------------------------');
     Writeln('  x      x*x    x*x*x       1/x  ');
     Writeln('---------------------------------');
     For x:=1 to 20 do
         Begin
              x2     := x*x;
              x3     := x*x*x;
              Seperx := 1/x;
              Writeln(x:3,x2:8,x:8,Seperx:12:3);
         End;
     Writeln('---------------------------------');
End.
59.
Program Perulangan_Mengunakan_Tabel_Tanpa_Statemen;
Uses WinCrt;
Var
   x : Integer;
Begin
     Writeln('---------------------------------');
     Writeln('  x      x*x    x*x*x       1/x  ');
     Writeln('---------------------------------');
     For x:=1 to 20 do
        Writeln(x:3,x*x:8,x*x*x:8,1./x:12:3);
     Writeln('---------------------------------');
End.
60.
Program Perulangan_Pertambahan_Nilai_Real;
Uses WinCrt;
Var
   x                   : Integer;
   Celcius, Fahrenheit : Real;
Begin
     Writeln(' ------------------------- ');
     Writeln('|  Celcius    Fahrenheit  |');
     Writeln(' ------------------------- ');
     Celcius := 0;
     For x:=1 to 10 do
         Begin
              Fahrenheit := 1.8 * Celcius + 32;
              Writeln(Celcius:8:2, Fahrenheit:14:2);
              Celcius := Celcius + 0.25;
         End;
     Writeln('---------------------------');
End.
61.
Program Perulangan_Negatip;
Uses WinCrt;
Var
   Celcius    : Integer;
   Fahrenheit : Real;
Begin
     Writeln(' ------------------------- ');
     Writeln('|  Celcius    Fahrenheit  |');
     Writeln(' ------------------------- ');
     Celcius := 0;
     For Celcius := 15 Downto 1 do
         Begin
              Fahrenheit := 1.8 * Celcius + 32;
              Writeln(Celcius:8, Fahrenheit:14:2);
         End;
     Writeln('---------------------------');
End.
62.
Program Perulangan_Tersarang;
Uses WinCrt;
Var
   I,J : Integer;
Begin
     For I:= 1 to 10 do
         Begin
              For J:= 1 to 6 do
                  Write(I:6, J:6);
              Writeln;
         End;
End.
63.
Program Struktur_Perulangan_While_do;
Uses WinCrt;
Var
   I : Integer;
Begin
     I := 0;
     While I < 5 Do
           Begin
                Writeln(I);
                I := I + 1;
           End;
End.
64.
Program Perulangan_While_do_Rata_Rata;

Uses WinCrt;

Var
   Nilai, Total, RataRata : Real;
   I, N                   : Integer;

Begin
     ClrScr;
     Write('Berapa Jumlah Data Yang Anda Masukkan ? ');
     Readln(n);
     Writeln;

     I     := 0;
     Total := 0;
     Nilai := 0;
     While i < n Do
           Begin
                i := i + 1;
                Write('Nilai data ke',i,' ? ');
                Readln(Nilai);
                Total := Total + Nilai;
           End;

               RataRata := Total/n;
              
               Writeln;
               Writeln('Total Nilai         = ',Total:8:2);Writeln;
               Writeln('Jumlah data         = ',n:4);Writeln;
               Writeln('Rata-rata nilai     = ',RataRata:8:2);Writeln;
               Writeln;
End.
65.
Program Perulangan_While_do_Rata_Rata_Komentar;
Uses WinCrt;
Var
   Nilai, Total, RataRata : Real;
   I, N                   : Integer;
   Lagi, T, Jawab            : Char;
Begin
     Lagi := 'Y';
     While (Lagi='Y') or (Lagi='y') do
           Begin
                ClrScr;
                Write('Berapa Jumlah Data Yang Anda Masukkan ? ');
                Readln(n);
                Writeln;
                I     := 0;
                Total := 0;
                Nilai := 0;
                While i < n Do
                      Begin
                           i := i + 1;
                           Write('Nilai data ke',i,' ? ');
                           Readln(Nilai);
                           Total := Total + Nilai;
                      End;
                      RataRata := Total/n;
                      Writeln;
                      Writeln('Total Nilai         = ',Total:8:2);Writeln;
                      Writeln('Jumlah data         = ',n:4);Writeln;
                      Writeln('Rata-rata nilai     = ',RataRata:8:2);Writeln;
                      Writeln;
                      Writeln('Anda Ingin Mengulang (Y/T) ? ');
                      Readln(Lagi);
                      ClrScr;
               if Lagi=T Then
                  ClrScr;
                  gotoxy(25,15);Writeln('TRIMAKASIH SEE U NEXT...!!!');            
           End;
end.
65.
Program Perulangan_While_do_Rata_Rata;
Uses WinCrt;
Var
   Nilai, Total, RataRata : Real;
   I, N                   : Integer;
   Lagi                   : Char;
Begin
     Lagi := 'Y';
     While (Lagi='Y') or (Lagi='y') do
           Begin
                ClrScr;
                Write('Berapa Jumlah Data Yang Anda Masukkan ? ');
                Readln(n);
                Writeln;
                I     := 0;
                Total := 0;
                Nilai := 0;
                While i < n Do
                      Begin
                           i := i + 1;
                           Write('Nilai data ke',i,' ? ');
                           Readln(Nilai);
                           Total := Total + Nilai;
                      End;
                      RataRata := Total/n;
                      Writeln;
                      Writeln('Total Nilai         = ',Total:8:2);Writeln;
                      Writeln('Jumlah data         = ',n:4);Writeln;
                      Writeln('Rata-rata nilai     = ',RataRata:8:2);Writeln;
                      Writeln;
                      Writeln('Anda Ingin Mengulang (Y/T) ? ');
                      Readln(Lagi);
                      ClrScr;
           End;
end.
66.
Program Repeat_Until;
Uses WinCrt;
Var
   I : Integer;
Begin
     I := 10;
     Repeat
           Writeln(I);
           I := I + 1;
     Until I < 5;
End.
67.
Program Struktur_While_do;
Uses WinCrt;
Var
   I : Integer;
Begin
     I := 10;
     While I < 5 Do
           Begin
                Writeln(I);
                I := I +1;
           End;
End.
68.
Program Repeat_Until_Blok_Ststemen;
Uses WinCrt;
Var
   Celcius, Fahrenheit : Real;
Begin
     Writeln('----------------------------');
     Writeln('   Celcius     Fahrenheit   ');
     Writeln('----------------------------');
     Celcius := 0;
     Repeat
           Begin
                Fahrenheit := 1.8 * Celcius + 32;
                Writeln(Celcius:8:2, Fahrenheit:14:2);
                Celcius:= Celcius + 0.5;
           End;
     Until Celcius > 5;
     Writeln('____________________________');
End.
69.
Program Perulangan_Struktur_Repeat_Until_Tersarang;
Uses WinCrt;
var
   a,b,c        : Real;
Begin
     Writeln('==================================');
     Writeln('   Sisi A     Sisi B     Sisi C   ');
     Writeln('----------------------------------');
     a := 1;
     Repeat
           b := 0;
           Repeat
                 c := Sqrt(a*a + b*b);
                 Writeln(a:8:2, b:11:2, c:11:2);
                 b := b+5;
           Until b >25;
           a := a +1;
     Until a > 3;
     Writeln('==================================');
End.
    __________________________________________________________________________
70.
Program Struktur_if_Then;
Uses WinCrt;
Var
   NilaiUjian : Real;
   Ket        : String[11];
Begin
     Ket := 'Tidak Lulus';
     Write('Nilai yang didapat? ');
     Readln(NilaiUjian);
     If NilaiUjian > 60 Then Ket := 'Lulus';
     Writeln(ket);
End.
71.
Program Struktur_If_Then_Komentar;
Uses WinCrt;
Var
   NilaiUjian  : Real;
   Ket         : String[11];
   Lagi,T,Jawab: Char;

Begin
     Lagi := 'Y';
     While (Lagi='Y') or (Lagi='y') do
           Begin
                Ket := 'Tidak Lulus';
                Write('Nilai yang didapat? ');
                Readln(NilaiUjian);
                If NilaiUjian > 60 Then Ket := 'Lulus';
                   Writeln(ket);
                   Writeln;  
                   Writeln('Ingin Mengulang (Y/T)? ');
                   Readln(Lagi);
                   ClrScr;
                   If Jawab=T Then
                      Writeln('Trims, see u next...!!!');
            End;
End.
72.
Program Penggunaan_Statemun_If_Then_Goto;
Uses WinCrt;
Label
     10;
Var
   R, T, Isi    : Real;
   Jawab        : Char;
Begin
     10: clrscr;
         Writeln;
         Write('Jari-jari Lingkaran ? ');
         Readln(R);
         Write('Tinggi Silinder     ? ');
         Readln(T);
         Isi := Pi * R * R * T;
         Writeln;
         Writeln('Isi Silinder = ',Isi:9:2);
         Writeln;
         Write('Menghitung Lagi (Y/T) ? ');
         Readln(Jawab);
         If (Jawab = 'Y') or (Jawab = 'y') Then
         Goto 10;
    
End.
73.
Program Sejumlah_Statemen_If_Then;
Uses WinCrt;
Var
   Pilihan      : Byte;
   R, L, T, Luas: Real;
Begin
     Gotoxy(10,2);Writeln('      <<<   PILIHAN    >>>    ');
     Gotoxy(10,4);Writeln('1. Menghitung Luas Lingkaran');
     Gotoxy(10,6);Writeln('2. Menghitung Luas Segitiga');
     Gotoxy(10,8);Writeln('3. Menghitung Luas Bujur-Sangkar');
     Gotoxy(10,10);Writeln('0.         SELESAI           ');
     Pilihan := 9;
     While (pilihan < 0) or (pilihan > 3) do
           begin
                Gotoxy(10,15);Write('Pilih nomor (0-3) ? ');Readln(Pilihan);
           end;

     ClrScr;
     If pilihan=1 Then
        Begin
             Write('Jari-jari Lingkaran ? ');
             Readln(R);
             Luas := PI * R * R;
             Writeln('Luas Lingkaran     = ',Luas:9:2);
        End;
     If Pilihan=2 Then
        Begin
             Write('Panjang sisi alas ? ');
             readln(L);
             Write('Tinggi Segitiga   ? ');
             Readln(T);
             Luas := 0.5 * L * T;
             Writeln('Luas segitiga    = ',Luas:9:2);
        End;
     If Pilihan=3 Then
        Begin
             Write('Panjang bujur sangkar ? ');
             readln(T);
             Write('Lebar Bujur sangkar   ? ');
             Readln(L);
             Luas := L * T;
             Write('Luas bujur sangkar   = ',Luas:9:2);
        End;   
End.
74.
Program Persamaan_Kuadrat_If_Then;
Uses WinCrt;
Var
   A,B,C,D,Z1,Z2,X1,X2 : Real;
   Lagi                : Char;
Begin
     Lagi := 'Y';
     While (Lagi='Y') or (Lagi='y') do
     Begin
          A := 0;
          While A=0 Do
          Begin
               Writeln;
               Write('Nilai A ? ');Readln(A);
          End;
          Write('Nilai B ? ');Readln(B);
          Write('Nilai C ? ');Readln(C);
          Writeln;
          D := B*B - 4*A*C;
          If D=0 Then
             Begin
                  X1 := -B/(2*A);
                  Writeln('Ada 2 akar kembar, yaitu : ');
                  writeln('X1 = X2 = ',X1:9:2);
             End
             Else
             Begin
                  If D > 0 Then
                     Begin
                          X1 := (-B + Sqrt(D))/(2*A);
                          X2 := (-B - Sqrt(D))/(2*A);
                          Writeln('Ada 2 akar real berlainan, yaitu : ');
                          writeln('x1 = ',x1:9:2);
                          writeln('x2 = ',x2:9:2);
                     End
                     Else
                     Begin
                          Z1 := -B / (2*A);
                          Z2 := Sqrt(-D) / (2*A);
                          Writeln('Ada dua akar imaginair berlainan, yaitu : ');
                          Writeln('X1 = ',Z1:9:2,' + ',Z2:9:2,'i');
                          Writeln('X2 = ',Z1:9:2,' - ',Z2:9:2,'i');
                     End
             End;
             Writeln;
             Write('Menghitung Lagi (Y/T) ? ');
             readln(Lagi);
             ClrScr;
     End;
End.
75.
Program Struktur_Case_Of;
Uses WinCrt;
Var
   Nilai : Char;
Begin
     Writeln('   GUNAKAN HURUF BESAR     ');
     Writeln('Nilai Huruf Yang Didapat ? ');
     Readln(Nilai);
     case Nilai of
          'A'  : writeln('Sangat baik');
          'B'  : writeln('baik');
          'C'  : writeln('Cukup');
          'D'  : writeln('Kurang');
          'E','F' : writeln('Gagal');
     end;
End.
76.
Program Case_Of_Calculator;
Uses WinCrt;
Var
   Nilai1, Nilai2, Hasil : Real;
   Operasi               : Char;
  
Begin
     ClrScr;
     Hasil := 0;
     Writeln('Operasi : | + | - | * | / |');
     Writeln;
     Writeln('Masukkan Nilai Dan Pilih Operasi Anda');
     Writeln('   N1 __  OP __ N2___  =    Hasil');
     Gotoxy(1,5);Writeln('[     ]');
     Gotoxy(10,5);Writeln('[ ]');
     Gotoxy(15,5);Writeln('[    ]');
     gotoxy(24,5);Writeln('=');
     Gotoxy(28,5);Writeln('[     ]');   

     Gotoxy(2,5);Readln(Nilai1);
     Gotoxy(11,5);Readln(Operasi);
     Gotoxy(16,5);Readln(Nilai2);

     Case Operasi Of
          '+' : Hasil := Nilai1 + Nilai2;
          '-' : Hasil := Nilai1 - Nilai2;
          '*' : Hasil := Nilai1 * Nilai2;
          '/' : Hasil := Nilai1 / Nilai2;
     End;

     Gotoxy(29,5);Writeln(Hasil:2:2);
End.
77.
Program Case_Of_Pembelian_Potongan;
Uses WinCrt;
Var
   Pembelian, Potongan : Integer;
Begin
     Writeln('Total Pembelian ? ');Readln(Pembelian);
     Writeln;
     Case Pembelian Of
          0..1000       : Potongan := 10;
          1001..10000 : Potongan := 500;
          10001..30000: Potongan := 2000;

     End;
     Writeln;
     Writeln('Jumlah Pembelian  = Rp',Pembelian:10);
     Writeln('Potongan          = Rp',Potongan:10);
     Writeln('                    -----------');
     Writeln('Jumlah dibayar    = Rp',Pembelian - Potongan:10);
End.
78.
Program Case_Of_Pilihan_Menu;
Uses WinCrt;
Var
   Pilihan                    : Byte;
   R,L,T,P,A,S,Luas,Volume    : Real;
   Lagi                       : Char;
Begin
     Lagi := 'Y';
     While (Lagi='Y') or (Lagi='y') do
Begin
     ClrScr;
     Writeln('SELAMAT DATANG DI PROGRAM LUAS DAN VOLUME BANGUN');
     Writeln;
     Gotoxy(16,2);Writeln('PILIHAN');
     Gotoxy(12,3);Writeln('1. Luas Lingkaran');
     Gotoxy(14,4);Writeln('2. Luas Segitiga');
     Gotoxy(16,5);Writeln('3. Luas Bujur Sangkar');
     Gotoxy(18,6);Writeln('4. Volume Kubus');
     Gotoxy(20,7);Writeln('5. Volume Balok');
     Gotoxy(22,8);Writeln('6. Volume Tabung');
     Gotoxy(24,9);Writeln('0. SELESAI');
     Writeln;

     Pilihan :=9;
     While (Pilihan < 0) Or (pilihan > 6) do
       Begin
            Gotoxy(10,10);Writeln('Pilih Nomer (0-6) ?');Readln(Pilihan);
       End;
       ClrScr;

       Case Pilihan Of

       1: Begin
               Write('Jari-Jari Lingkaran ? ');Readln(r);
               Luas := Pi * r * r;
               Writeln('Luas Lingkaran = ',Luas:2:2);
          End;
       2: Begin
               Write('Panjang Alas ? ');Readln(a);
               Write('Tinggi Segitiga ? ');Readln(t);
               Luas := 0.5 * a * t;
               Writeln('Luas Segitiga = ',Luas:2:2);
          End;
       3: Begin
               Write('Panjang Bujur Sangkar ? ');Readln(p);
               Write('Lebar Bujur Sangkar ? ');Readln(l);
               Luas := P * l;
               Writeln('Luas Bujur Sangakar = ',Luas:2:2);
          End;
       4: Begin
               Write('PanJang Sisi ? ');Readln(s);
               Volume := s * s * s;
               Writeln('Volume Kubus ? ',Volume:2:2);
          End;
       5: Begin
               Write('Panjang Balok ? ');Readln(p);
               Write('Lebar Balok ? ');Readln(l);
               Write('Tinggi Balok ? ');Readln(t);
               Volume := p * l * t;
               Writeln('Volume Balok = ',Volume:2:2);
          End;
       6: Begin
               Write('Jari-Jari Tabung ? ');Readln(r);
               Write('Tinggi Tabung ? ');Readln(t);
               Volume := Pi * r * r * t;
               Writeln('Volume Tabung = ',Volume:2:2);
          End;
          End;
          Writeln;
          Writeln('Ingin Mengulang (Y/T) ? ');Readln(Lagi);
          ClrScr;
   End;   
End.
79.
Program Case_Of_Pilihan_Menu;
Uses WinCrt;
Var
   Pilihan                     : Byte;
   R,L,T,P,A,S,B,d1,d2,Luas    : Real;
   Lagi                        : Char;
Begin
     Lagi := 'Y';
     While (Lagi='Y') or (Lagi='y') do
Begin
     ClrScr;
     Writeln('SELAMAT DATANG DI PROGRAM LUAS');
     Writeln;
     Gotoxy(16,2);Writeln('PILIHAN');
     Gotoxy(12,3);Writeln('1. Luas Lingkaran');
     Gotoxy(14,4);Writeln('2. Luas Segitiga');
     Gotoxy(16,5);Writeln('3. Luas Bujur Sangkar');
     Gotoxy(18,6);Writeln('4. LuasPersegi Panjang');
     Gotoxy(20,7);Writeln('5. Luas Jajaran Genjang');
     Gotoxy(22,8);Writeln('6. Luas Belah Ketupat');
     Gotoxy(24,9);Writeln('7. Luas Layang-Layang');
     Gotoxy(26,10);Writeln('8. Luas Trapesium');
     Gotoxy(28,11);Writeln('0. SELESAI');
     Writeln;

     Pilihan := 9;
     While (Pilihan < 0) Or (pilihan > 8) do
       Begin
            Gotoxy(10,12);Writeln('Pilih Nomer (0-8) ?');Readln(Pilihan);
       End;
       ClrScr;

       Case Pilihan Of

       1: Begin
               Write('Jari-Jari Lingkaran ? ');Readln(r);
               Luas := Pi * r * r;
               Writeln('Luas Lingkaran = ',Luas:2:2);
          End;
       2: Begin
               Write('Panjang Alas ? ');Readln(a);
               Write('Tinggi Segitiga ? ');Readln(t);
               Luas := 0.5 * a * t;
               Writeln('Luas Segitiga = ',Luas:2:2);
          End;
       3: Begin
               Write('Panjang Bujur Sangkar ? ');Readln(p);
               Write('Lebar Bujur Sangkar ? ');Readln(l);
               Luas := P * l;
               Writeln('Luas Bujur Sangakar = ',Luas:2:2);
          End;
       4: Begin
               Write('PanJang ? ');Readln(p);
               Write('Lebar ? ');Readln(l);
               Luas := p * l;
               Writeln('Luas Persegi Panjang ? ',Luas:2:2);
          End;
       5: Begin
               Write('Panjang alas ? ');Readln(p);
               Write('Tinggi ? ');Readln(t);
               Luas := a * t;
               Writeln('Luas Jajaran Genjang = ',Luas:2:2);
          End;
       6: Begin
               Write('Diagonal 1 ? ');Readln(r);
               Write('Diagonal 2 ? ');Readln(t);
               Luas := 0.5 * d1 * d2;
               Writeln('Luas Belah Ketupat = ',Luas:2:2);
          End;
       7: Begin
               Write('Diagonal 1 ? ');Readln(d1);
               Write('Diagonal 2 ? ');Readln(d2);
               Luas := 0.5 * d1 * d2;
               Writeln('Luas Layang-Layang = ',Luas:2:2);
          End;
       8: Begin
               Write('Panjang alas ? ');readln(a);
               Write('Panjang Bangun Atas ? ');Readln(b);
               Write('Tinggi Bangun ? ');Readln(t);
               Luas := (a +  b) / 2 * t;
               Writeln('Luas Trapesium = ',Luas:2:2);
          End;
          End;
          Writeln;
          Writeln('Ingin Mengulang (Y/T) ? ');Readln(Lagi);
          ClrScr;
   End;   
End.
80.
Program Merangakai_Nilai_string;
Uses WinCrt;
Const
     Jenis = 'Khoirul Arif';
     Nama  = 'Misbach Putro';
Var
   Sifat    : String[20];
   Kalimat  : String[80];
Begin
     Sifat := 'baik Dan Pendiam';
     Kalimat := Jenis+' '+Nama+' '+'Adalah Anak '+Nama+' '+Sifat;
     Writeln(Kalimat);
End.
81.
Program Penyeleksian_Kondisi_Ungkapan_String;
Uses WinCrt;
Var
   NamaBahasa : String[20];
Begin
     Write('Bahasa apa yang anda pergunakan ? ');
     Readln(NamaBahasa);
     If NamaBahasa = 'Pascal' Then
        Writeln('Benar !!!')
     Else
         Writeln('Salah !!!');
End.
82.
Program Seleksi_String_Kode_ASCII;
Uses WinCrt;
Var
   NamaAnda, NamaTeman : String[30];
Begin
     Write ('Nama Anda ? ');Readln(NamaAnda);
     Write('Nama Teman ? ');Readln(NamaTeman);
     If NamaAnda = NamaTeman Then
        Write('Nama Anda Sama Dengan Nama Teman Anda');
     If NamaAnda < NamaTeman Then
        Write('Nama Anda Urutannya Lebih Kecil Dari Teman Anda');
     If NamaAnda > NamaTeman Then
        Write('Nama Anda Urutannya Lebih Besar Dari Teman Anda');
End.
83.
Program Prosedur_Standart_Delete;
Uses WinCrt;
var
   Bahasa               : String[14];
   Urutan, Posisi       : Integer;
Begin
     Bahasa     := 'Khoirul Arifin';
     For Urutan := 1 to 14 do
     Begin
          Posisi := 16 - Urutan;
          Delete(Bahasa, Posisi, 1);
          Writeln(Bahasa);
     End;
End.
84.
Program Prosedur_Standar_Insert;
Uses WinCrt;
Var
   Nama : String[20];
Begin
     Nama := 'Khoirul Arifin MP';
     Writeln(Nama);
     Insert('.',Nama, 17);
     Writeln(Nama);
End.
85.
Program Prosedure_Standar_Str;
Uses WinCrt;
Var
   Nilai1, Nilai2 : Integer;
   X1, X2         : String[5];
Begin
     Nilai1 := 1234;
     Nilai2 := 567;
     Writeln(Nilai1+Nilai2);
     Str(Nilai1:4,X1);
     Str(Nilai2:4,X2);
     Writeln(X1+X2);
End.
86.
Program Prosedur_Standar_Val;
Uses WinCrt;
Var
   NilaiString   : String[6];
   NilaiReal    : Real;
   PosisiSalah  : Integer;
Begin
     NilaiString        := '123.45';
     Val(NilaiString, NilaiReal, PosisiSalah);
     Writeln('Nilai string : ',NilaiString);
     Writeln('Nilai Real   : ',NilaiReal);
     Writeln('Posisi Salah : ',PosisiSalah);
End.
87.
Program Prosedur_Standar_Val_ilai_Salah;
Uses WinCrt;
Var
   NilaiString   : String[6];
   NilaiReal    : Real;
   PosisiSalah  : Integer;
Begin
     NilaiString        := '123.K5';
     Val(NilaiString, NilaiReal, PosisiSalah);
     Writeln('Nilai string : ',NilaiString);
     Writeln('Nilai Real   : ',NilaiReal);
     Writeln('Posisi Salah : ',PosisiSalah);
End.
88.
Program Fungsi_Standar_Copy;
Uses WinCrt;
Var
   Karakter     : String[26];
Begin
     Karakter := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     Writeln(Karakter);
     Writeln(Copy(Karakter,5,3));
     Writeln(Copy(Karakter,10,13));
     Writeln(Copy(Karakter,1,26));
End.
__________________________________________________________________________-
89.
Program Standar_Copy_Untuk_Animasi_Karakter;
Uses WinCrt;
Var
   Kalimat     : String[12];
   Huruf        : Char;
   I,J          : Integer;
Begin
  Kalimat := 'Turbo Pascal';
 
    For i:= 1 to 13 Do
      Begin
         Writeln(Copy(Kalimat,I,1));
          For J:= 79 DownTo 33+I Do
            Begin
              Gotoxy(J,10);
              Writeln(Huruf,' ');
            End;
      End;
End.
90.
Program Standar_ConCat;
Uses WinCrt;
Const
     Nama = ' "Rumahku....... "';
     Dll  ='Adalah Surgaku';
Begin
     Writeln(ConCat('Pribahasa ',Nama,' Terusannya ',Dll));
End.
91.
Program Fungsi_Standar_Pos;
Uses WinCrt;
Const
    Alphabetik = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    Kar1       = 'FGHI';
    Kar2       = 'F';
    Kar3       = 'JUGA';
    Kar4       = 'DCB';
    Kar5       = 'PQRST';
Begin
  Writeln(Alphabetik);
  Writeln;
  Writeln(kar1,' ada di posisi ke ',pos(kar1,Alphabetik));
  Writeln(kar2,' ada di posisi ke ',pos(kar2,Alphabetik));
  Writeln(kar3,' ada di posisi ke ',pos(kar3,Alphabetik));
  Writeln(kar4,' ada di posisi ke ',pos(kar4,Alphabetik));
  Writeln(kar5,' ada di posisi ke ',pos(kar5,Alphabetik));
End.
92.
Program Fungsi_Pos_Jawaban;
Uses WinCrt;
Var
   Feet, Meter : Real;
   Lagi        : Char;
Begin
   Lagi := 'Y';
   While (Lagi='Y') or (Lagi='y') do
   Begin
      Writeln;
      Write('Berapa Feet ? ');
      Readln(Feet);
      Meter := Feet * 3.281;
      Writeln(Feet:7:2,' Feet dalah ',Meter:9:3,' meter');
      Writeln;
      Lagi := ' ';
      While Pos(Lagi,'YyTt') = 0 do
      Begin
         Write('Menghitung Lagi (Y/T)? ');
         Readln(Lagi);
      End;
   End;
End.
93.
Program Fungsi_Pos_Jawaban;
Uses WinCrt;
Var
   Feet, Meter, Inch, cm, mm : Real;
   Lagi        : Char;
Begin
   Lagi := 'Y';
   While (Lagi='Y') or (Lagi='y') do
   Begin
      Writeln;
      Write('Berapa Feet ? ');
      Readln(Feet);
      Writeln;
      Write('Berapa Inch ? ');
      Readln(Inch);
      Writeln;
      Meter := Feet * 3.281;
      Writeln(Feet:7:2,' Feet adalah ',Meter:9:3,' meter');
      Writeln;

      cm := Inch * 2.54;
      Writeln(Inch:7:2,' Inch adalah ',cm:9:3,' cm');
      Writeln;

      Lagi := ' ';
      While Pos(Lagi,'YyTt') = 0 do
      Begin
         Write('Menghitung Lagi (Y/T)? ');
         Readln(Lagi);
         ClrScr;
      End;
   End;
End.
94.
Program Standar_Length;
Uses WinCrt;
Var
   Nama_Anda : String[50];
Begin
   Write ('Masukkan Nama Anda ? ');
   Readln(Nama_Anda);
   Writeln('Panjang Nama Anda Adalah ',Length(Nama_Anda),' Karakter');
End.
95.
Program Run_Time_Error;
Uses WinCrt;
Var
   N, I, Faktorial : Integer;
Begin
   Writeln('Berapa Faktorial ? ');Readln(N);
   Faktorial := 1;
   For I:= 2 to n do Faktorial := Faktorial * I;
   Writeln;
   Writeln(N,' Faktorial = ',Faktorial);
End.
96.
Program Run_Time_Error_Diabaikan;
Uses WinCrt;
Var
   N, I, Faktorial : Integer;
   HasilIO         : Integer;
Begin
   Repeat
   {$I-}
   Writeln('Berapa Faktorial ? ');Readln(N);
   {$I+}

   HasilIO := IOResult;
   If HasilIO <> 0 Then
      Writeln('Data yang dimasukkan salah, ulangi !!!');

   Until HasilIO = 0;

   Faktorial := 1;
   For I:= 2 to n do Faktorial := Faktorial * I;
   Writeln;
   Writeln(N,' Faktorial = ',Faktorial);
End.
97.
Program Menunggu_Tekan_Tombol_Enter;
Uses WinCrt;
Begin
   Write('Tekanlah Tombol Enter...');Readln;
   ClrScr;
   Writeln('Halo apa Kabar ? ');
End.
98.
Program Menunggu_Tekan_Tombol_Sembarang;
Uses WinCrt;
Var
   I : Integer;
Begin
   While Not KeyPressed Do
         Writeln('Tekan Tombol Sembarang Untuk Berhenti ...');
End.
99.
Program Keypressed_Mempertahankan_tampilan_Layar;
Uses WinCrt;
Var
   X : Integer;
Begin
   Clrscr;
   Writeln('----------------------');
   Writeln('   X    X^2    X^3    ');
   Writeln('----------------------');
   For X:=1 to 30 do
      Begin
         If X=16 Then
         Begin
            Writeln;
            Writeln('Tekan sembarang tombol ...');
            Repeat Until Keypressed;
            Clrscr;
            Writeln('-----------------------');
            Writeln('   x    x^2    x^3     ');
            Writeln('-----------------------');
         End;
         Writeln(x:4,x*x:6,x*x*x:8);
      End;
End.
100.
Program Fungsi_standar_keypressed;
Uses WinCrt;
Var
   Tekan : Char;
Begin
   writeln('hallo apa kabar ? ');
   writeln;
   writeln('tekan sembarang tombol untuk mengetahui nama saya ...!!!');
   tekan := readkey;
   writeln;
   writeln('nama saya adalah Khoirul arief misbach putro');
end.
101.
Program Fungsi_standar_keypressed_memasukkan_tanpa_terlihat;
Uses WinCrt;
Var
   Tekan : Char;
Begin
   writeln;
   writeln('tekan sembarang tombol ...!!!');
   tekan := readkey;
   writeln;
   writeln('Yang anda tekan adalah tombol ',tekan);
end.
         --------------------------------------BERSAMBUNG -----------------------------------------

Tidak ada komentar:

Posting Komentar