Docstoc

modul tik turbo pascal

Document Sample
modul tik turbo pascal Powered By Docstoc
					                PENDAHULUAN                                       operator(=,<>,>,>        =,     <      =),    logical

1.1        Elemen-elemen TP                                       operator      (not,    and,         or),     address

a. Simbol-simbol dasar                                            operator(@ dan ^), set operator(+, -, *),

      TP dibentuk dari huruf(a, b, c, d, e, f, g, h,              string operator(+)

      I, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y,    1.2        Komenter program

      z), angka(1, 2, 3, 4, 5, 6, 7, 8, 9, 0), dan          TP menyediakan komentar untuk program

      karakter(~ ! @ # $ % ^ & * ( ) _ - + = )              dengan cara memberikan tanda { } dimana

b. Kata-kata cadangan                                       kalau ada tanda ini maka komputer tidak

      TP memberikan kata cadangan yang                      akan menjalankannya atau dilewat. Komenter

      lebih banyak lagi, diantaranya: absolute,             biasanya         digunakan     bila       dalam      tubuh

      and, array, begin, case, const, div, do,              program terdapat kondisi tertentu. Kondisi ini

      downto, else dan yang lainya.                         seperti program harus loncat (goto), program

c.    Tipe data                                             masuk suatu kondisi jika maka (If … than …

      TP     memberikan          kemudahan       dalam      else … )

      operasi matematika dan lebih banyak                   Untuk interaksi standar TP menyediakan:

      memory       untuk     mengaakses         tipe-tpe    Writeln(     „    ………        „);    berfungsi        untuk

      data, seperti:                                        menuliskan         data-data        atau         komentar

      Tipe byte ukuran memorinya 1 byte dan                 sedangkan write(„………‟); berfungsi untuk

      jangkauan data 0 s.d 255. Tipe longint                menanyakan            data         dan           pengguna

      ukuran memorinya 4 byte dan jangkauan                 memasukan data dari kayborad.

      data –2147483648 s.d 2147483647.
d. Pengenal program dapat dibuat sendiri
                                                                   Baca dulu saya
      Pengenal program dapat dibuat sendiri
      untuk     judul    program,       prosedur    dan      PERIKSA LISTRING PROGRAM DENGAN

      fungsi, seperti program latihan, prosedur                                 CARA KLIK F9

      hitung, function kali.                                BILA PROSES COMPILE BERHASIL MAKA

e. Karakter kontrol                                                            KLIK CTRL - F9

      TP      menyediakan           karakter-karakter         SELAMAT MENCOBA DAN BERKREASI

      spesial      untuk         digunakan      dimana            KALAU PRAKTEK DIKERJAKAN DI

      diformat dalam bahasa aschi, seperti #7                     SEKOLAH PADA SAAT JAM MASUK

      untuk bel, #65 karakter A. Selain itu bisa            KALAU TUGAS DIKERJAKAN DILUAR JAM

      menggunakan kontrol(^), contoh: ^G                     MASUK DAN DISIMPAN DALAM DISKET

      untuk bel, ^M untuk enter.                             SETIAP TUGAS DIKUMPULKAN MINGGU

f.    Operator hitungan/operasi                                                 BERIKUTNYA

      TP mengenal beberapa operator untuk                     BILA TIDAK MENGUMPULKAN TUGAS

      membantu hitungan atau operasi dalam                         SISWA DILARANG MENGIKUTI

      program           diantaranya,       assignment                           PELAJARAN

      operator (:=), binary operator (mod, div, -                              SELANJUTNYA

      ,+,*,^), unary operator(+ dan -), bitwisw
      operator(not,       and,    or,   xor),   relation




                                                     Halaman 1
PRAKTEK KE -1                                        WRITELN(„merupakan        barang       mati.
                                                    Peraturan – peraturan ini harus ditanamkan
LATIHAN WRITELN(‘ … … … ‘);
                                                    secara‟);
NAMA FILE : LAT1.PAS                                WRITELN(„bersinambungan        pada      tiap
                                                    anggota masyrakat sehingga dia benar-
PROGRAM PR1;
                                                    benar‟); WRITELN(„hidup dalam diri tiap
USES CRT;                                           orang. ‟);
                                                     WRITELN(„Menanamkan peraturan secara
BEGIN
                                                    berkesinambungan dapat dilakukan nelalui‟);
CLRSCR;                                             WRITELN(„pendidikan,      baik    pendidikan
                                                    formal (di sekolah ), maupun pendidikan‟);
WRITELN(„Kata disiplin diserap dari bahasa
                                                    WRITELN(„nonformal (dalam kursus –kursus
barat yang bermuasal dari bahasa latin‟);
                                                    dan latihan –latihan ), atau melalui‟);
WRITELN(„disciplin yang berarti “siasat,tata
                                                    WRITELN(„tindakan –tindakan incidental.
tertib,ketaatan,ajaran,pengajaran”.kata‟);
                                                    Tindakan     –tindakan   incidental   juga‟);
WRITELN(„kerja         disciplinare      berarti
                                                    WRITELN(„hendaknya sering dilaksanakan,
“mendidik,menggembleng,
                                                    bila tidak, sesudah tindakan incidental itu‟);
mengajar”.Dengan‟);       WRITELN(„demikian,
                                                    WRITELN(„berlalu anggota masyarakat yang
kata disiplin dapat diartikan “tindakan atau
                                                    biasanya tidak disiplin, akan kembali‟);
prilaku sesuai dengan‟);
                                                    WRITELN(„kepada kebiasaan semula . ‟);
WRITELN(„ajaran-ajaran yang telah diperoleh
seseorang,baik yang berupa undang ‟);
                                                    NAMA FILE : LAT3.PAS
WRITELN(„undang, peraturan, sopan santun,
                                                    PROGRAM SAYA;
adat istiadat, dan sebagainya”. ‟);
                                                    USES CRT;
WRITELN(„Dalam kehidupan pribadi disiplin
                                                    BEGIN
berarti peraturan yang dibuat untuk diri‟);
                                                    WRITELN(„ SAYA SISWA KELAS III DI
WRITELN(„sendiri,yang          tidak       boleh
                                                    SEBUAH SMA NEGERI„);
bertentangan dengan peraturan umum.
                                                    WRITELN(„ SAYA SEORANG SISWA YANG
Bangun dan‟);
                                                    RAJIN BELAJAR„);
WRITELN(„melakukan sesuatu tepat pada
                                                    WRITELN(„ SAYA KALAU DIBERI PR,
waktunya, hadir dalam suatu acara pada‟);
                                                    TUGAS ATAU APAPUN YANG„);
WRITELN(„waktu yang ditetapkan, atau
                                                    WRITELN(„    BERHUBUNGAN     DENGAN
melakukan tugas dan kewajiban dengan
                                                    SEKOLAH PASTI AKAN DI„);
tepat‟); WRITELN(„dan tertib hanya bisa
                                                    WRITELN(„ KERJAKAN DENGAN SERIUS
tercapai kalau ada disiplin pribadi. ‟);
                                                    DAN TEPAT WAKTU„);
REPEAT UNTIL KEYPRESSED;
                                                    WRITELN(„    TETAPI   SAYA    HERAN
END.
                                                    SEMENJAK ADA EBTANAS KEMUDIAN„);
                                                    WRITELN(„ DISUSUL UAN, KOK RASANYA
                                                    SEPERTI DIPERMAINKAN„);
NAMA FILE : LAT2.PAS
                                                    WRITELN(„ DARI SD KE SMP, NILAI
PROGRAM FISIKA;
                                                    EBTANAS/UAN DIPERHITUNGKAN„);
USES CRT;
                                                    WRITELN(„ DARI SMP KE SMA NILAI
BEGIN
                                                    EBTANAS/UAN DIPERHITUNGKAN„);
CLRSCR;
                                                    WRITELN(„ TETAPI NILAI UAN DARI SMA
WRITELN(„Dalam         skala nasional, kita
                                                    KE PTN ATAU PTS DI ACUHKAN„);
berbicara mengenai disiplin nasional, yaitu‟);
                                                    WRITELN(„     JADI   APA   GUNANYA
WRITELN(„bagaimana             tiap     orang
                                                    EBTANAS/UAN UNTUK SMA„);
melaksanakan peran mereka masing-masing
                                                    WRITELN(„ BUANG WAKTU, TENAGA, DAN
secara‟); WRITELN(„teratur sesuai dengan
                                                    DANA„);
pranata yang ada. Pranata dalam masyarakat
                                                    REPEAT UNTIL KEYPRESSED;
bangsa‟);     WRITELN(„biasanya        berupa
                                                    END.
peraturan, adapt kebiasaan, pedoman
pergaulan social, ‟); WRITELN(„sopan santun,
                                                    TUGAS 1
dan sebagainya. Semua pranata itu harus
                                                    Buatlah programnya
melembaga dalam‟); WRITELN(„diri tiap
                                                    BUKU SUMBER FISIKA KLS 2 UNTUK SMU
warga masyarakat bukan hanya berada di
                                                    KELAS 2
atas kertas. Peraturan baru‟);
NOABSEN         MATERI             HALAMAN
1/11/21/31      KEDUDUKAN PADA BIDANG1
2/12/22/32      PERPINDAHAN             PADA        7/17/27/37      PERPADUAN DUA            GLB
BIDANG          2                                                   6
3/13/23/33      KECEPATAN RATA-RATA                 8/18/28/38      GERAK PARABOLA
                3                                           10
4/14/24/34      KECEPATAN SESAAT                    9/19/29/39  GERAK       MELINGKAR
        4                                           BERATURAN 13
5/15/25/35      PERCEPATAN RATA-RATA                10/20/30/40 GAYA SENTRIPETAL
        5                                                   14
6/16/26/36      MEMADU                   DUA
PERPINDAHAN               5



                                             Halaman 2
                                           RATA := (N1+N2+N3)/3;
PRAKTEK KE – 2                             WRITELN(„NAMA SISWA        : „,NAMA);
LATIHAN WRITE(‘ … ‘);READLN(…);            WRITELN(„PELAJARAN         :
                                           „,PELAJARAN);
NAMA FILE : LAT4.PAS                       WRITELN(„ NILAI KE 1, 2, 3 :
PROGRAM HITUNGAN;                          „,N1,N2,N3);
USES CRT;                                  WRITELN(„RATA-RATA                :
CONST                                      „,RATA);
A = 2; B = 4; C = 6;                       REPEAT UNTIL KEYPRESSED;
VAR                                        END.
X, TAM,BAG,KUR,KAL : REAL;
BEGIN                                      TUGAS 2
CLRSCR;                                    Buatlah programnya
WRITELN(„HITUNGAN‟);                       BUKU SUMBER FISIKA KLS 2 UNTUK SMU
WRITELN(„TIGA ANGKA‟);                     KELAS 2
WRITELN(„A=2 B=4 C=6‟);                    NOABSEN        CONTOH      HALAMAN
WRITELN(„BILANGAN BARU‟);
WRITE(„ANGKA:„);READLN(X);                 1/11/21/31    KEDUDUKAN        PADA
TAM := (A+X)+(B+X)+(C+X);                  BIDANG        1
BAG := (A/X)+(B/X)+(C/X);                  2/12/22/32    PERPINDAHAN      PADA
KAL := (A*X)+(B*X)+(C*X);                  BIDANG        2
WRITELN(„HASIL1= „,TAM);                   3/13/23/33    KECEPATAN RATA-RATA
WRITELN(„HASIL2= „,BAG);                                 3
WRITELN(„HASIL3= „,KAL);                   4/14/24/34    KECEPATAN SESAAT
REPEAT UNTIL KEYPRESSED;                           4
END.                                       5/15/25/35  PERCEPATAN RATA-RATA
                                                   5
NAMA FILE : LAT5.PAS                       6/16/26/36  MEMADU            DUA
PROGRAM BIDANG;                            PERPINDAHAN       5
USES CRT;                                  7/17/27/37  PERPADUAN DUA GLB
VAR                                                    6
P,T,L,R,S,A,LS,LL,LEP,LBS : REAL;          8/18/28/38  GERAK PARABOLA
BEGIN                                              10
CLRSCR;                                    9/19/29/39  GERAK       MELINGKAR
WRITELN(„ LUAS BIDANG‟);                   BERATURAN 13
WRITE(„PANJANG:„);READLN(P);               10/20/30/40 GAYA SENTRIPETAL
WRITE(„ LEBAR:„);READLN(L);                        14
WRITE(„TINGGI:„);READLN(T);
WRITE(„JARI2:„);READLN(R);
WRITE(„SISI:„);READLN(S);
WRITE(„ALAS:„);READLN(A);                  PRAKTEK KE- 3
LL := 3.14*R*R;                            NAMA FILE : LAT7.PAS
LEP := P*L;                                PROGRAM BAYAR;
LS := 0.5*A*T;                             USES CRT;
LBS := S*S;                                CONST
WRITELN(„LUAS LINGKARAN = „, LL ,‟M2‟);    DI1= -1000; DI2 =-1100;DI3=-1200;DI4=1400;
WRITELN(„ LUAS SEGITIGA = „, LS ,‟M2‟);    VAR
WRITELN(„ LUAS 4PERSEGI PANJANG = „,       NB1,NB2,NB3,NB4 : STRING;
LEP ,‟M2‟);                                HB1,HB2,HB3,HB4,JB1.JB2.JB3.JB4,BY1,B
WRITELN(„ LUAS BUJUR SANGKAR = „,          Y2,
LBS ,‟M2‟);                                BY3,BY4,UM,UK,TOTAL           : REAL;
REPEAT UNTIL KEYPRESSED;                   BEGIN
END.                                       CLRSCR;
                                           WRITELN(„MENGHITUNG PEMBAYARAN‟);
NAMA FILE : LAT6.PAS                       WRITE(„NAMA BARANG KE-1 :
PROGRAM NILAI;                             „);READLN(NB1);
USES CRT;                                  WRITE(„HARGA BARANG KE-1 :
VAR                                        „);READLN(HB1);
PELAJARAN,NAMA : STRING;                   WRITE(„JUMLAH BARANG KE-1             :
N1,N2,N3, RATA : REAL;                     „);READLN(JB1);
BEGIN                                      WRITE(„NAMA BARANG KE-2 :
CLRSCR;                                    „);READLN(NB2);
WRITELN(„PROGRAM MENGHITUNG NILAI          WRITE(„HARGA BARANG KE-2 :
RATA-RATA ULANGAN‟);                       „);READLN(HB2);
WRITE(„NAMA SISWA :„);                     WRITE(„JUMLAH BARANG KE-2             :
READLN(PELAJARAN);                         „);READLN(JB2);
WRITE(„NILAI KE-1    : „);READLN(N1);      WRITE(„NAMA BARANG KE-3 :
WRITE(„NILAI KE-2    : „);READLN(N2);‟     „);READLN(NB3);
WRITE(„NILAI KE-3    : „);READLN(N3);

                                    Halaman 3
WRITE(„HARGA BARANG KE-3 :                            WRITELN(Y1:2);
„);READLN(HB3);                                       WRITELN(Y2:2);
WRITE(„JUMLAH BARANG KE-3       :                     WRITELN(Y3:2);
„);READLN(JB3);                                       WRITELN(Y4:2);
WRITE(„NAMA BARANG KE-4 :                             WRITELN(Y5:2);
„);READLN(NB4);                                       WRITELN(Y6:2);
WRITE(„HARGA BARANG KE-4 :                            WRITELN(Y7:2);
„);READLN(HB4);                                       WRITELN(Y8:2);
WRITE(„JUMLAH BARANG KE-4       :                     WRITELN(Y9:2);
„);READLN(JB4);                                       WRITELN(Y10:2);
WRITE(„UANG MUKA = „);READLN(UM);                     WRITELN(Y11:2);
                                                      WRITELN(Y12:2);
BY1 := HB1*JB1-JB1*DI1;                               WRITELN(Y13:2);
BY2 := HB2*JB2-JB2*DI2;                               WRITELN(Y14:2);
BY3 := HB3*JB3-JB3*DI3;                               WRITELN(Y15:2);
BY4 := HB4*JB4-JB4*DI4;                               WRITELN(Y16:2);
TOTAL := BY1+BY2+BY3+BY4;
UK := UM-TOTAL;                                       PROGRAM LAT;
WRITELN(„TOKO SAGALA AYA‟);                           USES CRT;
WRITELN(„NOTA BAYAR : KONTAN‟);                       VAR
WRITELN(„--------------------------------„);          SUDUT,SINUS,COSINUS,TANGEN,SECAN,
WRITELN(„NAMA BARANG KE-1 :,NB1);                     COSECAN,COTANGEN:REAL;
WRITELN(„HARGA:,HB1);                                 BEGIN
WRITELN(„JUMLAH:,JB1);                                CLRSCR;
WRITELN(„BAYAR            :,BY1);                     WRITE(SUDUT = „);READLN(SUDUT);
WRITELN(„NAMA BARANG KE-2 :,NB2);                     SINUS:= SIN(SUDUT/57.3);
WRITELN(„HARGA:,HB2);                                 COSINUS:=COS(SUDUT/57.3);
WRITELN(„JUMLAH           :,JB2);                     TANGEN:=SINUS/COSINUS;
WRITELN(„BAYAR            :,BY2);                     SECAN:=1/COSINUS;
WRITELN(„NAMA BARANG KE-3 :,NB3);                     COSECAN:=1/SINUS;
WRITELN(„HARGA:,HB3);                                 COTANGEN:=1/TANGEN;
WRITELN(„JUMLAH           :,JB3);                     WRITELN(SUDUT,SINUS:2);
WRITELN(„BAYAR            :,BY3);                     WRITELN(SUDUT,COSINUS:2);
WRITELN(„NAMA BARANG KE-4 :,NB4);                     WRITELN(SUDUT,TANGEN:2);
WRITELN(„HARGA            :,HB4);                     WRITELN(SUDUT,SECAN:2);
WRITELN(„JUMLAH           :,JB4);                     WRITELN(SUDUT,COSECAN:2);
WRITELN(„BAYAR            :,BY4);                     WRITELN(SUDUT,COTANGEN:2);
WRITELN(„ TUNAI,UM);                                  WRITELN(SUDUT,SINUS+SINUS);
WRITELN(„KONTAN‟,TOTAL);                              WRITELN(SUDUT,SINUS+COSINUS);
WRITELN(„KEMBALI‟,UK);                                WRITELN(SUDUT,SINUS+TANGEN);
REPEAT UNTIL KEYPRESSED;                              WRITELN(SUDUT,SINUS+SECAN);
END.                                                  WRITELN(SUDUT,SINUS+COSECAN);
                                                      WRITELN(SUDUT,SINUS+COTANGEN);
PROGRAM PERSAMAAN;                                    WRITELN(SUDUT,COSINUS+SINUS);
USES CRT;                                             WRITELN(SUDUT,COSINUS+COSINUS);
VAR                                                   WRITELN(SUDUT,COSINUS+TANGEN);
A,B,C,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11              WRITELN(SUDUT,COSINUS+SECAN);
,Y12,Y13,Y14,Y15,Y16 : REAL;                          WRITELN(SUDUT,COSINUS+COSECAN);
BEGIN                                                 WRITELN(SUDUT,COSINUS+COTANGEN);
CLRSCR;
WRITE(„A= „);READLN(A);                               TUGAS 3
WRITE(„B= „);READLN(B);                               BUATLAH PROGRAMNYA
WRITE(„C= „);READLN(C);                               Dalam ilmu fisika terdapat materi gerak
Y1:=(A+B)+C;                                          beraturan.
Y2:=(A+B)/C;                                          Benda bergerak dengan persamaan gerak
Y3:=(A+B)*C;                                          pada sumbu x yaitu rx = 2 t, pda sumbu y
Y4:=(A+B)-C;                                          yaitu ry = 4 t, dan pada sumbu x yaitu rz = 6 t.
Y5:=(A/B)+C;                                          dimana t dalam detik. Benda tersebut bererak
Y6:=(A/B)/C;                                          menuju titik A dan B dalam waktu 2 dan 5
Y7:=(A/B)*C;                                          detik.
Y8:=(A/B)-C;                                          Jika massa benda 2 kg. Tentukan:
Y9:=(A*B)+C;                                              a. jarak tempuh titik A (rxa, rxb, rya,
Y10:=(A*B)/C;                                                  ryb, rza, rzb) pada waktu 2 detik
Y11:=(A*B)*C;                                             b. jarak tempuh titik B (rxa, rxb, rya, ryb,
Y12:=(A*B)-C;                                                  rza, rzb) pada waktu 5 detik
Y13:=(A-B)+C;                                             c. kecepatan benda di titik A (vxa, vxb,
Y14:=(A-B)/C;                                                  vya, vyb, vza,vzb)
Y15:=(A-B)*C;                                                  catatan: v = r / t
Y16:=(A-B)-C;

                                               Halaman 4
   d. kecepatan benda di titik B (vxa, vxb,      GOTOXY(32,5);WRITELN(J3);
      vya, vyb, vza,vzb)                         GOTOXY(32,6);WRITELN(J4);
      catatan: v = r / t                         GOTOXY(32,7);WRITELN(J5);
   e. percepatan benda di titik A (axa, axb,     GOTOXY(32,8);WRITELN('TOTAL');
      aya, ayb, aza,azb)                         GOTOXY(42,3);WRITELN(B1:2);
      catatan: a = v / t                         GOTOXY(42,4);WRITELN(B2:2);
   f. percepatan benda di titik B (axa, axb,     GOTOXY(42,5);WRITELN(B3:2);
      aya, ayb, aza,azb)                         GOTOXY(42,6);WRITELN(B4:2);
      catatan: a = v / t                         GOTOXY(42,7);WRITELN(B5:2);
   g. gaya benda pada titik A (Fxa, Fxb,         GOTOXY(42,8);WRITELN((B1+B2+B3+B4+B
      Fya, Fyb, Fza, Fzb)                        5):2);
      catatan: F = m a
   h. gaya benda pada titik B (Fxa, Fxb,         REPEAT UNTIL KEYPRESSED;
      Fya, Fyb, Fza, Fzb)                        END.
      catatan: F = m a
   i. Energi kinetic pada titik A ( Exa, Exb,
      Eya, Eyb, Eza, Ezb)                        PROGRAM GTXY2;
      Catatan: E = m v v / 2                     PROGRAM GTXY;
   j. Energi kinetic pada titik B ( Exa, Exb,    USES CRT;
      Eya, Eyb, Eza, Ezb)                        VAR
      Catatan: E = m v v / 2                     NB1,NB2,NB3,NB4,NB5 : STRING;
                                                 H1,H2,H3,H4,H5,J1,J2,J3,J4,J5,B1,B2,B3,B4
PRAKTEK KE-4                                     ,B5 : REAL;
LATIHAN GOTOXY(X,Y);                             BEGIN
PROGRAM GTXY;                                    CLRSCR;
USES CRT;                                        WRITE('NAMA BARANG KE1 =
CONST                                            ');READLN(NB1);
H1=100;                                          WRITE('NAMA BARANG KE2 =
H2=200;                                          ');READLN(NB2);
H3=300;                                          WRITE('NAMA BARANG KE3 =
H4=400;                                          ');READLN(NB3);
H5=500;                                          WRITE('NAMA BARANG KE4 =
J1=1;                                            ');READLN(NB4);
J2=2;                                            WRITE('NAMA BARANG KE5 =
J3=3;                                            ');READLN(NB5);
J4=4;                                            WRITE('JUMLAH BARANG KE1 =
J5=5;                                            ');READLN(J1);
                                                 WRITE('JUMLAH BARANG KE2 =
VAR                                              ');READLN(J2);
B1,B2,B3,B4,B5 : REAL;                           WRITE('JUMLAH BARANG KE3 =
BEGIN                                            ');READLN(J3);
CLRSCR;                                          WRITE('JUMLAH BARANG KE4 =
B1:=H1*J1;                                       ');READLN(J4);
B2:=H2*J2;                                       WRITE('JUMLAH BARANG KE5 =
B3:=H3*J3;                                       ');READLN(J5);
B4:=H4*J4;                                       WRITE('HARGA BARANG KE1 =
B5:=H5*J5;                                       ');READLN(H1);
GOTOXY(2,2);WRITELN('NO');                       WRITE('HARGA BARANG KE2 =
GOTOXY(12,2);WRITELN('BARANG');                  ');READLN(H2);
GOTOXY(22,2);WRITELN('HARGA');                   WRITE('HARGA BARANG KE3 =
GOTOXY(32,2);WRITELN('JUMLAH');                  ');READLN(H3);
GOTOXY(42,2);WRITELN('BAYAR');                   WRITE('HARGA BARANG KE4 =
GOTOXY(2,3);WRITELN('1');                        ');READLN(H4);
GOTOXY(2,4);WRITELN('2');                        WRITE('HARGA BARANG KE5 =
GOTOXY(2,5);WRITELN('3');                        ');READLN(H5);
GOTOXY(2,6);WRITELN('4');                        CLRSCR;
GOTOXY(2,7);WRITELN('5');                        B1:=H1*J1;
GOTOXY(12,3);WRITELN('A');                       B2:=H2*J2;
GOTOXY(12,4);WRITELN('B');                       B3:=H3*J3;
GOTOXY(12,5);WRITELN('C');                       B4:=H4*J4;
GOTOXY(12,6);WRITELN('D');                       B5:=H5*J5;
GOTOXY(12,7);WRITELN('E');                       GOTOXY(2,2);WRITELN('NO');
GOTOXY(22,3);WRITELN(H1);                        GOTOXY(12,2);WRITELN('BARANG');
GOTOXY(22,4);WRITELN(H2);                        GOTOXY(22,2);WRITELN('HARGA');
GOTOXY(22,5);WRITELN(H3);                        GOTOXY(32,2);WRITELN('JUMLAH');
GOTOXY(22,6);WRITELN(H4);                        GOTOXY(42,2);WRITELN('BAYAR');
GOTOXY(22,7);WRITELN(H5);                        GOTOXY(2,3);WRITELN('1');
GOTOXY(32,3);WRITELN(J1);                        GOTOXY(2,4);WRITELN('2');
GOTOXY(32,4);WRITELN(J2);                        GOTOXY(2,5);WRITELN('3');

                                          Halaman 5
GOTOXY(2,6);WRITELN('4');                 GOTOXY(22,7);WRITELN('3');
GOTOXY(2,7);WRITELN('5');                 GOTOXY(22,8);WRITELN('4');
GOTOXY(12,3);WRITELN('A');                GOTOXY(22,9);WRITELN('5');
GOTOXY(12,4);WRITELN('B');                GOTOXY(22,10);WRITELN('6');
GOTOXY(12,5);WRITELN('C');                GOTOXY(22,11);WRITELN('7');
GOTOXY(12,6);WRITELN('D');                GOTOXY(22,12);WRITELN('8');
GOTOXY(12,7);WRITELN('E');                GOTOXY(22,13);WRITELN('9');
GOTOXY(22,3);WRITELN(H1:8:2);             GOTOXY(22,14);WRITELN('10');
GOTOXY(22,4);WRITELN(H2:8:2);             LU1:=P1*L1;
GOTOXY(22,5);WRITELN(H3:8:2);             LU2:=P2*L2;
GOTOXY(22,6);WRITELN(H4:8:2);             LU3:=P3*L3;
GOTOXY(22,7);WRITELN(H5:8:2);             LU4:=P4*L4;
GOTOXY(32,3);WRITELN(J1:8:2);             LU5:=P5*L5;
GOTOXY(32,4);WRITELN(J2:8:2);             LU6:=P6*L6;
GOTOXY(32,5);WRITELN(J3:8:2);             LU7:=P7*L7;
GOTOXY(32,6);WRITELN(J4:8:2);             LU8:=P8*L8;
GOTOXY(32,7);WRITELN(J5:8:2);             LU9:=P9*L9;
GOTOXY(32,8);WRITELN('TOTAL');            LU10:=P10*L10;
GOTOXY(42,3);WRITELN(B1:8:2);             GOTOXY(32,5);WRITELN(LU1:5:0);
GOTOXY(42,4);WRITELN(B2:8:2);             GOTOXY(32,6);WRITELN(LU2:5:0);
GOTOXY(42,5);WRITELN(B3:8:2);             GOTOXY(32,7);WRITELN(LU3:5:0);
GOTOXY(42,6);WRITELN(B4:8:2);             GOTOXY(32,8);WRITELN(LU4:5:0);
GOTOXY(42,7);WRITELN(B5:8:2);             GOTOXY(32,9);WRITELN(LU5:5:0);
GOTOXY(42,8);WRITELN((B1+B2+B3+B4+B       GOTOXY(32,10);WRITELN(LU6:5:0);
5):8:2);                                  GOTOXY(32,11);WRITELN(LU7:5:0);
REPEAT UNTIL KEYPRESSED;                  GOTOXY(32,12);WRITELN(LU8:5:0);
END.                                      GOTOXY(32,13);WRITELN(LU9:5:0);
                                          GOTOXY(32,14);WRITELN(LU10:5:0);
                                          REPEAT UNTIL KEYPRESSED;
PROGRAM LETAK1;                           END.
USES WINCRT;
CONST                                     NAMA FILE : LAT18.PAS
P1=100;P2=200;P3=300;P4=400;P5=500;       {PROGRAM MENGHITUNG GAJI}
P6=600;P7=700;P8=800;P9=900;P10=1000;     PROGRAM GAJI;
L1=1;L2=2;L3=3;L4=4;L5=5;                 USES CRT;
L6=6;L7=7;L8=8;L9=9;L10=10;               CONST
VAR                                       K1='A'; GAP1=1000000;
LU1,LU2,LU3,LU4,LU5,LU6,LU7,              K2='B'; GAP2=5000000;
LU8,LU9,LU10 : REAL;                      K3='C'; GAP3=9000000;
BEGIN                                     K4='A'; GAP4=2000000;
CLRSCR;                                   K5='A'; GAP5=1000000;
GOTOXY(2,2);WRITELN('MENEMPATKAN          K6='A'; GAP6=1000000;
HURUP');                                  K7='B'; GAP7=6000000;
GOTOXY(2,4);WRITELN('NO');                K8='B'; GAP8=5000000;
GOTOXY(12,4);WRITELN('PANJANG');          K9='A'; GAP9=1000000;
GOTOXY(22,4);WRITELN('LEBAR');            K10='C'; GAP10=9000000;
GOTOXY(32,4);WRITELN('LUAS');             GOL1=1;
GOTOXY(2,5);WRITELN('1');                 GOL2=2;
GOTOXY(2,6);WRITELN('2');                 GOL3=3;
GOTOXY(2,7);WRITELN('3');                 GOL4=2;
GOTOXY(2,8);WRITELN('4');                 GOL5=1;
GOTOXY(2,9);WRITELN('5');                 GOL6=1;
GOTOXY(2,10);WRITELN('6');                GOL7=3;
GOTOXY(2,11);WRITELN('7');                GOL8=2;
GOTOXY(2,12);WRITELN('8');                GOL9=1;
GOTOXY(2,13);WRITELN('9');                GOL10=3;
GOTOXY(2,14);WRITELN('10');               JJ1=1;
GOTOXY(12,5);WRITELN('100');              JJ2=5;
GOTOXY(12,6);WRITELN('200');              JJ3=8;
GOTOXY(12,7);WRITELN('300');              JJ4=14;
GOTOXY(12,8);WRITELN('400');              JJ5=3;
GOTOXY(12,9);WRITELN('500');              JJ6=6;
GOTOXY(12,10);WRITELN('600');             JJ7=9;
GOTOXY(12,11);WRITELN('700');             JJ8=10;
GOTOXY(12,12);WRITELN('800');             JJ9=20;
GOTOXY(12,13);WRITELN('900');             JJ10=24;
GOTOXY(12,14);WRITELN('1000');            S1=1;
GOTOXY(22,5);WRITELN('1');                S2=1;
GOTOXY(22,6);WRITELN('2');                S3=1;

                                   Halaman 6
S4=0;                                  GOTOXY(2,4);WRITELN('2');
S5=1;                                  GOTOXY(2,5);WRITELN('3');
S6=0;                                  GOTOXY(2,6);WRITELN('4');
S7=0;                                  GOTOXY(2,7);WRITELN('5');
S8=0;                                  GOTOXY(2,8);WRITELN('6');
S9=1;                                  GOTOXY(2,9);WRITELN('7');
S10=0;                                 GOTOXY(2,10);WRITELN('8');
A1=2;                                  GOTOXY(2,11);WRITELN('9');
A2=3;                                  GOTOXY(2,12);WRITELN('10');
A3=1;                                  GOTOXY(5,3);WRITELN('AA');
A4=0;                                  GOTOXY(5,4);WRITELN('BB');
A5=3;                                  GOTOXY(5,5);WRITELN('CC');
A6=0;                                  GOTOXY(5,6);WRITELN('DD');
A7=0;                                  GOTOXY(5,7);WRITELN('EE');
A8=0;                                  GOTOXY(5,8);WRITELN('FF');
A9=3;                                  GOTOXY(5,9);WRITELN('GG');
A10=0;                                 GOTOXY(5,10);WRITELN('HH');
J1='P';                                GOTOXY(5,11);WRITELN('II');
J2='Q';                                GOTOXY(5,12);WRITELN('JJ');
J3='R';                                GOTOXY(10,3);WRITELN('A');
J4='P';                                GOTOXY(10,4);WRITELN('B');
J5='P';                                GOTOXY(10,5);WRITELN('C');
J6='P';                                GOTOXY(10,6);WRITELN('A');
J7='Q';                                GOTOXY(10,7);WRITELN('A');
J8='Q';                                GOTOXY(10,8);WRITELN('A');
J9='P';                                GOTOXY(10,9);WRITELN('B');
J10='R';                               GOTOXY(10,10);WRITELN('B');
N01=1;                                 GOTOXY(10,11);WRITELN('A');
NAMA1=('AA');                          GOTOXY(10,12);WRITELN('C');
KE=('A');                              GOTOXY(22,3);WRITELN('1');
NO2=2;                                 GOTOXY(22,4);WRITELN('2');
NAMA2=('BB');                          GOTOXY(22,5);WRITELN('3');
KF=('B');                              GOTOXY(22,6);WRITELN('2');
NO3=3;                                 GOTOXY(22,7);WRITELN('1');
NAMA3=('CC');                          GOTOXY(22,8);WRITELN('1');
KG=('C');                              GOTOXY(22,9);WRITELN('3');
NO4=4;                                 GOTOXY(22,10);WRITELN('2');
NAMA4=('DD');                          GOTOXY(22,11);WRITELN('1');
NO5=5;                                 GOTOXY(22,12);WRITELN('3');
NAMA5=('EE');                          GOTOXY(26,3);WRITELN('1');
NO6=6;                                 GOTOXY(26,4);WRITELN('5');
NAMA6=('FF');                          GOTOXY(26,5);WRITELN('8');
NO7=7;                                 GOTOXY(26,6);WRITELN('14');
NAMA7=('GG');                          GOTOXY(26,7);WRITELN('3');
NO8=8;                                 GOTOXY(26,8);WRITELN('6');
NAMA8=('HH');                          GOTOXY(26,9);WRITELN('9');
NO9=9;                                 GOTOXY(26,10);WRITELN('10');
NAMA9=('II');                          GOTOXY(26,11);WRITELN('20');
NO10=10;                               GOTOXY(26,12);WRITELN('24');
NAMA10=('JJ');                         GOTOXY(30,3);WRITELN('1');
                                       GOTOXY(30,4);WRITELN('1');
VAR                                    GOTOXY(30,5);WRITELN('1');
NO,NAMA,KODE,JAB,GAP,GOL,JUMJAM,S      GOTOXY(30,6);WRITELN('0');
TATUS,                                 GOTOXY(30,7);WRITELN('1');
ANAK,TUNIS,TUNAK,PTKPS,PTKPI,PTKPA,    GOTOXY(30,8);WRITELN('0');
PTKP,                                  GOTOXY(30,9);WRITELN('0');
PKP,GABER:REAL;                        GOTOXY(30,10);WRITELN('0');
BEGIN                                  GOTOXY(30,11);WRITELN('1');
CLRSCR;                                GOTOXY(30,12);WRITELN('0');
GOTOXY(2,2);WRITELN('NO');             GOTOXY(35,3);WRITELN('2');
GOTOXY(5,2);WRITELN('NAMA');           GOTOXY(35,4);WRITELN('3');
GOTOXY(10,2);WRITELN('KOD');           GOTOXY(35,5);WRITELN('1');
GOTOXY(14,2);WRITELN('JAB');           GOTOXY(35,6);WRITELN('0');
GOTOXY(18,2);WRITELN('GAP');           GOTOXY(35,7);WRITELN('3');
GOTOXY(22,2);WRITELN('GOL');           GOTOXY(35,8);WRITELN('0');
GOTOXY(26,2);WRITELN('JUM');           GOTOXY(35,9);WRITELN('0');
GOTOXY(30,2);WRITELN('STAT');          GOTOXY(35,10);WRITELN('0');
GOTOXY(35,2);WRITELN('ANAK');          GOTOXY(35,11);WRITELN('3');
GOTOXY(2,3);WRITELN('1');              GOTOXY(35,12);WRITELN('0');

                                Halaman 7
IF              K1='A'           THEN    IF             A2=3               THEN
GOTOXY(14,3);WRITELN('P');               GOTOXY(7,4);WRITELN(25*GAP2*A2/100);
IF              K2='B'           THEN    IF             A3=1               THEN
GOTOXY(14,4);WRITELN('Q');               GOTOXY(7,5);WRITELN(25*GAP3*A3/100);
IF              K3='C'           THEN    IF A4=0 THEN GOTOXY(7,6);WRITELN(0);
GOTOXY(14,5);WRITELN('R');               IF             A5=3               THEN
IF              K4='A'           THEN    GOTOXY(7,7);WRITELN(25*GAP5*A5/100);
GOTOXY(14,6);WRITELN('P');               IF A6=0 THEN GOTOXY(7,8);WRITELN(0);
IF              K5='A'           THEN    IF A7=0 THEN GOTOXY(7,9);WRITELN(0);
GOTOXY(14,7);WRITELN('P');               IF A8=0 THEN GOTOXY(7,10);WRITELN(0);
IF              K6='A'           THEN    IF             A9=3               THEN
GOTOXY(14,8);WRITELN('P');               GOTOXY(7,11);WRITELN(25*GAP9*A9/100)
IF              K7='B'           THEN    ;
GOTOXY(14,9);WRITELN('Q');               IF             A10=0              THEN
IF              K8='B'           THEN    GOTOXY(7,12);WRITELN(0);
GOTOXY(14,10);WRITELN('Q');              GOTOXY(12,3);WRITELN(GAP1*JJ1/50);
IF              K9='A'           THEN    GOTOXY(12,4);WRITELN(GAP2*JJ2/50);
GOTOXY(14,11);WRITELN('P');              GOTOXY(12,5);WRITELN(GAP3*JJ3/50);
IF              K10='C'          THEN    GOTOXY(12,6);WRITELN(GAP4*JJ4/50);
GOTOXY(14,12);WRITELN('R');              GOTOXY(12,7);WRITELN(GAP5*JJ5/50);
IF   (J1='P')   AND     (GOL1=1) THEN    GOTOXY(12,8);WRITELN(GAP6*JJ6/50);
GOTOXY(18,3);WRITELN(GAP1);              GOTOXY(12,9);WRITELN(GAP7*JJ7/50);
IF   (J2='Q')   AND     (GOL2=2) THEN    GOTOXY(12,10);WRITELN(GAP8*JJ8/50);
GOTOXY(18,4);WRITELN(GAP2);              GOTOXY(12,10);WRITELN(GAP9*JJ9/50);
IF   (J3='R')   AND     (GOL3=3) THEN    GOTOXY(12,11);WRITELN(GAP10*JJ10/50);
GOTOXY(18,5);WRITELN(GAP3);              GOTOXY(18,3);WRITELN(GAP1*JJ1/100);
IF   (J4='P')   AND     (GOL4=2) THEN    GOTOXY(18,4);WRITELN(GAP2*JJ2/100);
GOTOXY(18,6);WRITELN(GAP4);              GOTOXY(18,5);WRITELN(GAP3*JJ3/100);
IF   (J5='P')   AND     (GOL5=1) THEN    GOTOXY(18,6);WRITELN(GAP4*JJ4/100);
GOTOXY(18,7);WRITELN(GAP5);              GOTOXY(18,7);WRITELN(GAP5*JJ5/100);
IF   (J6='P')   AND     (GOL6=1) THEN    GOTOXY(18,8);WRITELN(GAP6*JJ6/100);
GOTOXY(18,8);WRITELN(GAP6);              GOTOXY(18,9);WRITELN(GAP7*JJ7/100);
IF   (J7='Q')   AND     (GOL7=3) THEN    GOTOXY(18,10);WRITELN(GAP8*JJ8/100);
GOTOXY(18,9);WRITELN(GAP7);              GOTOXY(18,11);WRITELN(GAP9*JJ9/100);
IF   (J8='Q')   AND     (GOL8=2) THEN    GOTOXY(18,12);WRITELN(GAP10*JJ10/100
GOTOXY(18,10);WRITELN(GAP8);             );
IF   (J9='P')   AND     (GOL9=1) THEN    GOTOXY(26,3);WRITELN(GAP1*JJ1/150);
GOTOXY(18,11);WRITELN(GAP9);             GOTOXY(26,4);WRITELN(GAP2*JJ2/150);
IF    (J10='R')   AND(GOL10=3)   THEN    GOTOXY(26,5);WRITELN(GAP3*JJ3/150);
GOTOXY(18,12);WRITELN(GAP10);            GOTOXY(26,6);WRITELN(GAP4*JJ4/150);
READLN;                                  GOTOXY(26,7);WRITELN(GAP5*JJ5/150);
CLRSCR;                                  GOTOXY(26,8);WRITELN(GAP6*JJ6/150);
GOTOXY(2,2);WRITELN('TUNI');             GOTOXY(26,9);WRITELN(GAP7*JJ7/150);
GOTOXY(7,2);WRITELN('TUNA');             GOTOXY(26,10);WRITELN(GAP8*JJ8/150);
GOTOXY(12,2);WRITELN('PTKPS');           GOTOXY(26,11);WRITELN(GAP9*JJ9/150);
GOTOXY(18,2);WRITELN('PTKPI');           GOTOXY(26,12);WRITELN(GAP10*JJ10/150
GOTOXY(26,2);WRITELN('PTKPA');           );
GOTOXY(34,2);WRITELN('PTKP');            GOTOXY(34,3);WRITELN((GAP1*JJ1/50)+(
GOTOXY(40,2);WRITELN('PKP');             GAP1*JJ1/100)+(GAP1*JJ1/150));
GOTOXY(47,2);WRITELN('GABER');           GOTOXY(34,4);WRITELN((GAP2*JJ2/50)+(
IF               S1=1            THEN    GAP2*JJ2/100)+(GAP2*JJ2/150));
GOTOXY(2,3);WRITELN(50*GAP1/100);        GOTOXY(34,5);WRITELN((GAP3*JJ3/50)+(
IF               S2=1            THEN    GAP3*JJ3/100)+(GAP3*JJ3/150));
GOTOXY(2,4);WRITELN(50*GAP2/100);        GOTOXY(34,6);WRITELN((GAP4*JJ4/50)+(
IF               S3=1            THEN    GAP4*JJ4/100)+(GAP4*JJ4/150));
GOTOXY(2,5);WRITELN(50*GAP3/100);        GOTOXY(34,7);WRITELN((GAP5*JJ5/50)+(
IF S4=0 THEN GOTOXY(2,6);WRITELN(0);     GAP5*JJ5/100)+(GAP5*JJ5/150));
IF               S5=1            THEN    GOTOXY(34,8);WRITELn((GAP6*JJ6/50)+(G
GOTOXY(2,7);WRITELN(50*GAP5/100);        AP6*JJ6/100)+(GAP6*JJ6/150));
IF S6=0 THEN GOTOXY(2,8);WRITELN(0);     GOTOXY(34,9);WRITELN((GAP7*JJ7/50)+(
IF S7=0 THEN GOTOXY(2,9);WRITELN(0);     GAP7*JJ7/100)+(GAP7*JJ7/150));
IF S8=0 THEN GOTOXY(2,10);WRITELN(0);    GOTOXY(34,10);WRITELN((GAP8*JJ8/50)+(
IF               S9=1            THEN    GAP8*JJ8/100)+(GAP8*JJ8/150));
GOTOXY(2,11);WRITELN(50*GAP9/100);       GOTOXY(34,11);WRITELN((GAP9*JJ9/50)+(
IF              S10=0            THEN    GAP9*JJ9/100)+(GAP9*JJ9/150));
GOTOXY(2,12);WRITELN(0);                 GOTOXY(34,12);WRITELN((GAP10*JJ10/50
IF               A1=2            THEN    )+(GAP10*JJ10/100)+(GAP10*JJ10/150));
GOTOXY(7,3);WRITELN(25*GAP1*A1/100);


                                  Halaman 8
GOTOXY(40,3);WRITELN((GAP1*JJ1)-           X5=32;
(GAP1*JJ1/50)+(GAP1*JJ1/100)+(GAP1*JJ1/    X6=42;
150));                                     X7=43;
GOTOXY(40,4);WRITELN((GAP2*JJ2)-           X8=53;
(GAP2*JJ2/50)+(GAP2*JJ2/100)+(GAP2*JJ2/    X9=54;
150));                                     X10=64;
GOTOXY(40,5);WRITELN((GAP3*JJ3)-           X11=3;
(GAP3*JJ3/50)+(GAP3*JJ3/100)+(GAP3*JJ3/    X12=2;
150));                                     X13=8;
GOTOXY(40,6);WRITELN((GAP4*JJ4)-           X14=5;
(GAP4*JJ4/50)+(GAP4*JJ4/100)+(GAP4*JJ4/    X15=3;
150));                                     VAR
GOTOXY(40,7);WRITELN((GAP5*JJ5)-           X16,X17,X18,X19,X20,
(GAP5*JJ5/50)+(GAP5*JJ5/100)+(GAP5*JJ5/    X21,X22,X23,X24,X25,
150));                                     X26,X27,X28,X29,X30,
GOTOXY(40,8);WRITELN((GAP6*JJ6)-           X31,X32,X33,X34,X35,
(GAP6*JJ6/50)+(GAP6*JJ6/100)+(GAP6*JJ6/    X36,X37,X38,X39,X40,
150));                                     X41,X42,X43,X44,X45,
GOTOXY(40,9);WRITELN((GAP7*JJ7)-           X46,rata,b,f1,f2,b1,b2,n,me,xo:real;
(GAP7*JJ7/50)+(GAP7*JJ7/100)+(GAP7*JJ7/    p:INTEGER;
150));                                     BEGIN
GOTOXY(40,10);WRITELN((GAP8*JJ8)-          CLRSCR;
(GAP8*JJ8/50)+(GAP8*JJ8/100)+(GAP8*JJ8/    X16:=(X1+X2)/2;
150));                                     X17:=(X3+X4)/2;
GOTOXY(40,11);WRITELN((GAP9*JJ9)-          X18:=(X5+X6)/2;
(GAP9*JJ9/50)+(GAP9*JJ9/100)+(GAP9*JJ9/    X19:=(X7+X8)/2;
150));                                     X20:=(X9+X10)/2;
GOTOXY(40,12);WRITELN((GAP10*JJ10)-        X21:=-2;
(GAP10*JJ10/50)+(GAP10*JJ10/100)+(GAP1     X22:=-1;
0*JJ10/150));                              X23:=0;
GOTOXY(47,3);WRITELN((GAP1*JJ1/50)+(       X24:=1;
GAP1*JJ1/100)+(GAP1*JJ1/150)+(50*GAP1/     X25:=2;
100)+(25*GAP1*A1/100));                    x26:=x21*x21;
GOTOXY(47,4);WRITELN((GAP2*JJ2/50)+(       X27:=X22*X22;
GAP2*JJ2/100)+(GAP2*JJ2/150)+(50*GAP2/     X28:=X23*X23;
100)+(25*GAP2*A2/100));                    X29:=X24*X24;
GOTOXY(47,5);WRITELN((GAP3*JJ3/50)+(       X30:=X25*X25;
GAP3*JJ3/100)+(GAP3*JJ3/150)+(50*GAP3/     X31:=X11*X21;
100)+(25*GAP3*A3/100));                    X32:=X12*X22;
GOTOXY(47,6);WRITELN((GAP4*JJ4/50)+(       X33:=X13*X23;
GAP4*JJ4/100)+(GAP4*JJ4/150)+(0)+(0));     X34:=X14*X24;
GOTOXY(47,7);WRITELN((GAP5*JJ5/50)+(       X35:=X15*X25;
GAP5*JJ5/100)+(GAP5*JJ5/150)+(50*GAP5/     X36:=X31*X31;
100)+(25*GAP5*A5/100));                    X37:=X32*X32;
GOTOXY(47,8);WRITELN((GAP6*JJ6/50)+(       X38:=X33*X33;
GAP6*JJ6/100)+(GAP6*JJ6/150)+(0)+(0));     X39:=X34*X34;
GOTOXY(47,9);WRITELN((GAP7*JJ7/50)+(       X20:=X34*X35;
GAP7*JJ7/100)+(GAP7*JJ7/150)+(0)+(0));     X41:=X11+X12+X13+X14+X15;
GOTOXY(47,10);WRITELN((GAP8*JJ8/50)+(      X42:=X16+X17+X18+X19+X20;
GAP8*JJ8/100)+(GAP8*JJ8/150)+(0)+(0));     X43:=X21+X22+X23+X24+X25;
GOTOXY(47,11);WRITELN((GAP9*JJ9/50)+(      X44:=X26+X27+X28+X29+X30;
GAP9*JJ9/100)+(GAP9*JJ9/150)+(50*GAP9/     X45:=X31+X32+X33+X34+X35;
100)+(25*GAP9*A9/100));                    X46:=X36+X37+X38+X39+X40;
GOTOXY(47,12);WRITELN((GAP10*JJ10/50       xo:=X18;
)+(GAP10*JJ10/100)+(GAP10*JJ10/150)+(0)    b:=x4+x5/2;
+(0));                                     p:=10;
READLN;                                    n:=x42;
END.                                       f1:=x11+x12;
                                           f2:=x13;
NAMA FILE : LAT19B.PAS                     b1:=x13-x12;
{program statistic}                        b2:=x13-x14;
PROGRAM STATISTIK;                         rata:=((xo+p)*(x45/x41));
USES                                       me:=b+p*((1/2*n)-f1)/f2;
CRT;                                       xo:=b+p*(b1/(b2+b1));
CONST                                      gotoxy (2,2);writeln ('interval');
X1=10;                                     gotoxy (12,2);writeln ('f');
X2=20;                                     gotoxy (22,2);writeln ('x');
X3=21;                                     gotoxy (32,2);writeln ('ci');
X4=31;                                     gotoxy (42,2);writeln ('ci2');

                                    Halaman 9
gotoxy (52,2);writeln ('fici');             JUMLAH = N1 + N2
gotoxy (62,2);writeln ('fici2');            RATA2 = JUMLAH/2
gotoxy (2,3);writeln (x1,'-',x2);
gotoxy (2,4);writeln (x3,'-',x4);           SOAL 2
gotoxy (2,5);writeln (x5,'-',x6);           DARI TABEL BERIKUT:
                                                                       2 2
gotoxy (2,6);writeln (x7,'-',x8);           NO       X        Y      X Y XY
gotoxy (2,7);writeln (x9,'-',x10);          1        N        N+10
gotoxy (12,3);writeln (x11:0);              2        N+11
gotoxy (12,4);writeln (x12:0);              3
gotoxy (12,5);writeln (x13:0);              4
gotoxy (12,6);writeln (x14:0);              5
gotoxy (12,7);writeln (x15:0);              6
gotoxy (22,3);writeln (x16:5:0);            7
gotoxy (22,4);writeln (x17:5:0);            8
gotoxy (22,5);writeln (x18:5:0);            9
gotoxy (22,6);writeln (x19:5:0);            10
gotoxy (22,7);writeln (x20:5:0);            JUMLAH
gotoxy (32,3);writeln (x21:5:0);            N = 10
gotoxy (32,4);writeln (x22:5:0);            TENTUKAN NILAI A, B, C, D, E, F
gotoxy (32,5);writeln (x23:5:0);            DENGAN RUMUSAN:
gotoxy (32,6);writeln (x24:5:0);            A = N [JUMXY]
gotoxy (32,7);writeln (x25:5:0);            B = [JUM X] [JUM Y]
                                                            2          2
gotoxy (42,3);writeln (x26:5:0);            C = N [JUM X ] – [JUM X]
                                                            2          2
gotoxy (42,4);writeln (x27:5:0);            D = N [JUM Y ] – [JUM Y]
gotoxy (42,5);writeln (x28:5:0);            E=[CD]
gotoxy (42,6);writeln (x29:5:0);            F = [ A – B ] / SQRT [ E ]
gotoxy (42,7);writeln (x30:5:0);
gotoxy (52,3);writeln (x31:5:0);            SOAL 3
gotoxy (52,4);writeln (x32:5:0);            NO     INTERVAL
                                                                                    2
gotoxy (52,5);writeln (x33:5:0);                   N1 N2 FI XI       CI FICI FICI
gotoxy (52,6);writeln (x34:5:0);            1      N N+10 3          3
gotoxy (52,7);writeln (x35:5:0);            2      N+11    4         2
gotoxy (62,3);writeln (x36:5:0);            3              3         1
gotoxy (62,4);writeln (x37:5:0);            4              10 XO      0
gotoxy (62,5);writeln (x38:5:0);            5              2         -1
gotoxy (62,6);writeln (x39:5:0);            6              6         -2
gotoxy (62,7);writeln (x40:5:0);            7              2         -3
gotoxy (2,8);writeln ('jumlah');            8              8         -4
gotoxy (12,8);writeln (x41:5:0);            9              7         -5
gotoxy (22,8);writeln (x42:5:0);            10             2         -6
gotoxy (32,8);writeln (x43:5:0);            JUMLAH
gotoxy (42,8);writeln (x44:5:0);            N = 10
gotoxy (2,12);writeln ('rata=');
gotoxy (2,13);writeln ('me=');              DARI      TABEL      DIATAS     TENTUKAN
                                                   2
gotoxy (2,14);writeln ('mo=');              RATA NYA(X)
gotoxy (12,12);writeln (rata:5:0);          XI = [ N1 + N2 ] / 2
gotoxy (12,13);writeln (me:5:0);            P = 10
                                                                  2
gotoxy (12,14);writeln (Mo:5:0);            X = XO + P [ JUM FICI / JUM FI]
repeat until keypressed;
end.
                                            PRAKTEK KE-5
                                            PROGRAM MENGULANG
TUGAS 4                                     DAN SUATU KONDISI
BUATLAH PROGRAMNYA DARI TABEL               FOR… TO … DO …
BERIKUT:
                                            PROGRAM ULANG1;
SOAL 1                                      USES CRT;
                                            VAR
NO NAMA N1 N2 JUMLAH RATA2                  I: INTEGER;
1 A 2 4                                     BEGIN
2 B 4 5                                     CLRSCR;
3 C 8 6                                     GOTOXY(2,2);WRITELN('NILAI A');
4 D 4 3                                     GOTOXY(12,2);WRITELN('NILAI B');
5 E 3 7                                     GOTOXY(22,2);WRITELN('NILAI A+B');
6 F 5 8                                     FOR I := 1 TO 10 DO
7 G 8 3                                     BEGIN
8 H 4 5                                     GOTOXY(2,2+I);WRITE(2*I);
9 I 7 9                                     GOTOXY(12,2+I);WRITE(2+2*I);
10 J 6 3                                    GOTOXY(22,2+I);WRITE(2+I+2*I+2);

                                     Halaman 10
END;                                    END.
READLN;
END.                                    TUGAS 5
                                        BUATLAH PROGRAMNYA DARI TABEL
PROGRAM ULANG1;                         BERIKUT:
USES CRT;
VAR                                     NO    A B C A+B+C A+(B/C)
I: INTEGER;                             1     5 6 7
N1,N2,JUMLAH : REAL;                    2     7 9 10
NAMA:STRING;                            3     9 12 13
                                        4     11 15 16
BEGIN                                   5     13 18 19
CLRSCR;                                 6     15 21 22
FOR I := 1 TO 3 DO                      7     17 24 25
BEGIN                                   8     19 27 28
                                        9     21 30 31
GOTOXY(2,2);WRITELN('NAMA');            10    23 33 34
GOTOXY(2,4);WRITELN('NILAI 1');
GOTOXY(2,6);WRITELN('NILAI 2');
GOTOXY(12,2);READLN(NAMA);              PRAKTEK KE-6
GOTOXY(12,4);READLN(N1);                PROGRAM MENGULANG
GOTOXY(12,6);READLN(N2);                DAN SUATU KONDISI
CLRSCR;                                 WHILE …..
JUMLAH:=N1+N2;
GOTOXY(2,10);WRITELN(N1,N2,JUMLAH);     PROGRAM ULANG1;
END;                                    USES CRT;
READLN;                                 VAR
END.                                    I: INTEGER;
                                        BEGIN
NAMA FILE : LAT11.PAS                   CLRSCR;
PROGRAM FORTODO;                        GOTOXY(2,2);WRITELN('NILAI A');
USES CRT;                               GOTOXY(12,2);WRITELN('NILAI B');
VAR                                     GOTOXY(22,2);WRITELN('NILAI A+B');
X : INTEGER;
CEL,FAH : REAL;                         I:=0;
BEGIN                                   WHILE I < 20 DO
CLRSCR;                                 BEGIN
WRITELN(„CELCIUS                        I := I + 1;
        FAHRENHEIT ‟);                  GOTOXY(2,2+I);WRITE(2*I);
CEL := 0;                               GOTOXY(12,2+I);WRITE(2+2*I);
FOR X := 1 TO 100 DO                    GOTOXY(22,2+I);WRITE(2+I+2*I+2);
BEGIN                                   END;
FAH := 1.8*CEL+32;                      READLN;
WRITE(CEL:8:2,FAH:14:2);                END.
CEL := CEL+0.5;
END;                                    NAMA FILE : LAT12.PAS
REPEAT UNTIL KEYPRESSED;                PROGRAM WHILEDO;
END.                                    USES CRT;
                                        VAR
PROGRAM ULANG2;                         N,TOTAL,RATA-RATA : REAL;
USES CRT;                               X,I : INTEGER;
VAR                                     BEGIN
I : INTEGER;                            CLRSCR;
BEGIN                                   WRITE(„BANYAK DATA : „);READLN(N);
CLRSCR;                                 I := 0;
GOTOXY(2,2);WRITELN('NO');              TOTAL := 0;
GOTOXY(12,2);WRITELN('A');              WHILE I < N DO
GOTOXY(22,2);WRITELN('B');              BEGIN
GOTOXY(32,2);WRITELN('A+B');            I := I +1;
                                        WRITE(„NILAI   DATA    KE    „,I,‟   ?   ‟
                                        );READLN(N);
FOR I:= 1 TO 10 DO                      TOTAL := TOTAL + N;
BEGIN                                   END;
GOTOXY(2,2+I);WRITE(I);                 RATARATA := TOTAL/N;
GOTOXY(12,2+I);WRITE(2*I);              WRITELN;
GOTOXY(22,2+I);WRITE(3*I);              WRITELN(„TOTAL NILAI                 :
GOTOXY(32,2+I);WRITE(2*I+3*I);          „,TOTAL:8:2);
END;                                    WRITELN(„JUMLAH DATA       : „,N:3);
READLN;

                                 Halaman 11
WRITELN(„RATA-RATA      :                    CLRSCR;
„,RATARATA:8:2);                             IF PIL='A' THEN
REPEAT UNTIL KEYPRESSED;                     BEGIN
END.                                         WRITE('A');READLN(R);
                                             WRITE('b');READLN(L);
NAMA FILE : LAT13.PAS                        WRITE('C');READLN(T);
PROGRAM ULANGBERTANYA;                       Y:=(R+L)+T;
USES CRT;                                    WRITELN('Y1',Y:20:1);
VAR                                          END;
X : INTEGER;
CEL,FAH : REAL;                              IF PIL='B' THEN
LAGI : CHAR;                                 BEGIN
BEGIN                                        WRITE('A');READLN(L);
CLRSCR;                                      WRITE('b');READLN(T);
LAGI := „Y‟;                                 WRITE('C');READLN(R);
WHILE LAGI = „Y‟ DO                          Y:=(L+T)-R;
BEGIN                                        WRITELN('Y2',Y:9:2);
CLRSCR;                                      END;
WRITE(„DERAJAT=„);READLN(CEL);
FAH := 1.8*CEL+32;                           IF PIL='C' THEN
WRITELN(„ FAHRENHEIT :‟,FAH:8:2);            BEGIN
WRITE(„ULANG        LAGI   (Y/T)        ?    WRITE('A');READLN(R);
„);READLN(LAGI);                             WRITE('b');READLN(L);
END;                                         WRITE('C');READLN(T);
REPEAT UNTIL KEYPRESSED;                     Y:=(R+L)/T;
END.                                         WRITELN('Y3',Y:9:2);
                                             END;
TUGAS KE 6
BUATLAH                   PROGRAMNYA         IF PIL='D' THEN
MENGGUNAKAN WHILE .. DO:                     BEGIN
   1. Menghitung luas lingkaran, segitiga,   WRITE('A');READLN(R);
      empat persegi panjang                  WRITE('b');READLN(L);
   2. Menghitung persamaan Y=(A+B)+C         WRITE('C');READLN(T);
                                             Y:=(R+L)*T;
PRAKTEK KE-7                                 WRITELN('Y4',Y:9:2);
LATIHAN IF … THEN … ELSE                     END;
NAMA FILE : LAT15.PAS
PROGRAM IF_THEN;                             IF PIL='E' THEN
USES CRT;                                    BEGIN
VAR                                          WRITE('A');READLN(R);
PIL:STRING[1];                               WRITE('b');READLN(L);
R,L,T,Y:REAL;                                WRITE('C');READLN(T);
BEGIN                                        Y:=(R-L)+T;
CLRSCR;                                      WRITELN('Y5',Y:9:2);
GOTOXY(10,2);WRITELN('PILIHAN');             END;
GOTOXY(10,6);WRITELN('A,Y1');
GOTOXY(10,7);WRITELN('B,Y2');                IF PIL='F' THEN
GOTOXY(10,8);WRITELN('C,Y3');                BEGIN
GOTOXY(10,9);WRITELN('D,Y4');                WRITE('A');READLN(R);
GOTOXY(10,10);WRITELN('E,Y5');               WRITE('b');READLN(L);
GOTOXY(10,11);WRITELN('F,Y6');               WRITE('C');READLN(T);
GOTOXY(10,12);WRITELN('G,Y7');               Y:=(R-L)-T;
GOTOXY(10,13);WRITELN('H,Y8');               WRITELN('Y6',Y:9:2);
GOTOXY(10,14);WRITELN('I,Y9');
GOTOXY(10,15);WRITELN('J,Y10');              END;
GOTOXY(10,16);WRITELN('K,Y11');
GOTOXY(10,17);WRITELN('L,Y12');              IF PIL='G' THEN
GOTOXY(10,18);WRITELN('M,Y13');              BEGIN
GOTOXY(10,19);WRITELN('N,Y14');              WRITE('A');READLN(R);
GOTOXY(10,20);WRITELN('O,Y14');              WRITE('b');READLN(L);
GOTOXY(10,21);WRITELN('P,Y16');              WRITE('C');READLN(T);
                                             Y:=(R-L)/T;
                                             WRITELN('Y7',Y:9:2);
WHILE(PIL<'A')OR(PIL>'Q')DO
BEGIN                                        END;
GOTOXY(10,23);WRITE('PILIH
ANDA?');READLN(PIL);                         IF PIL='H' THEN
END;                                         BEGIN
                                             WRITE('A');READLN(R);

                                      Halaman 12
WRITE('B');READLN(L);
WRITE('C');READLN(T);           END;
Y:=(R-L)*T;                     IF PIL='P' THEN
WRITELN('Y8',Y:9:2);            BEGIN
                                WRITE('A');READLN(R);
END;                            WRITE('B');READLN(L);
                                WRITE('C');READLN(T);
IF PIL='I' THEN                 Y:=(R*L)*T;
BEGIN                           WRITELN('Y16',Y:9:2);
WRITE('A');READLN(R);           END;
WRITE('b');READLN(L);           END.
WRITE('C');READLN(T);
Y:=(R/L)+T;                     NAMA FILE : LAT16.PAS
WRITELN('Y9',Y:20:1);           PROGRAM IF_THEN_ELSE;
END;                            USES CRT;
                                VAR
IF PIL='J' THEN                 A,B,C,D,Z1,Z2,X1,X2 : REAL;
BEGIN                           LAGI : CHAR;
WRITE('A');READLN(R);           BEGIN
WRITE('b');READLN(L);           LAGI := „Y‟
WRITE('C');READLN(T);           WHILE (LAGI=‟Y‟) OR (LAGI=‟y‟);
Y:=(R/L)-T;                     BEGIN
WRITELN('Y10',Y:20:2);          A := 0;
                                WHILE A = 0 DO
END;                            BEGIN
                                WRITE(„NILAI A ? „);READLN(A);
IF PIL='K' THEN                 END;
BEGIN                           WRITE(„NILAI B ?        „);READLN(B);
WRITE('A');READLN(R);           WRITE(„NILAI C ? „);READLN( C );
WRITE('b');READLN(L);           D := B*B – 4*A*C;
WRITE('C');READLN(T);           IF D = 0 THEN
Y:=(R/L)/T;                     BEGIN
WRITELN('Y11',Y:20:2);          X1 := -B/(2*A);
END;                            WRITELN(„ADA 2 AKAR KEMBAR, YAITU
                                :‟);
IF PIL='L' THEN                 WRITELN(„X1 = X2 : „,X1:9:2);
BEGIN                           END
WRITE('A');READLN(R);           ELSE
WRITE('b');READLN(L);           BEGIN
WRITE('C');READLN(T);           IF D > 0 THEN
Y:=(R/L)*T;                     BEGIN
WRITELN('Y12',Y:20:2);          X1 := (-B+SQRT(D))/(2*A);
END;                            X2 := (-B-SQRT(D))/(2*A);
                                WRITELN(„ADA 2 AKAR BERLAINAN,
IF PIL='M' THEN                 YAITU‟);
BEGIN                           WRITE(„X1 = „,X1:9:2);
WRITE('A');READLN(R);           WRITE(„X2 = „,X2:9:2);
WRITE('b');READLN(L);           END
WRITE('C');READLN(T);           ELSE
Y:=(R*L)+T;                     BEGIN
WRITELN('Y13',Y:20:2);          Z1 := -B/(2*A);
END;                            Z2 := SQRT(-D)/(2*A);
                                WRITELN(ADA 2 AKAR IMAJINER, YAITU‟);
IF PIL='N' THEN                 WRITELN(„X1 = ‟, Z1:9:2 ,‟ + ‟, Z2:9:2, „I‟);
BEGIN                           WRITELN(„X2 = ‟, Z1:9:2 ,‟ - ‟, Z2:9:2, „I‟);
WRITE('A');READLN(R);           END;
WRITE('b');READLN(L);           END;
WRITE('C');READLN(T);           WRITE(LAGI (Y/T) ? „); READLN(LAGI);
Y:=(R*L)-T;                     END;
WRITELN('Y14',Y:20:2);          END.

END;
IF PIL='O' THEN                 TUGAS KE – 7
BEGIN                           BUATLAH PROGRAMNYA:
WRITE('A');READLN(R);
WRITE('b');READLN(L);                 1. MENU UNTUK MENGHITUNG
WRITE('C');READLN(T);                      A. V = S / T
Y:=(R*L)/T;                                B. A = S / T T
WRITELN('Y15',Y:20:2);                     C. F = M S / T T

                         Halaman 13
          D. E = M V V / 2                    1:
                                              BEGIN
   2. MENU UNTUK MENGHITUNG                      WRITE('A=');READLN(A);
        A. LUAS LINGKARAN                        WRITE('B=');READLN(B);
        B. LUAS 4PERSEGIPANJANG                  WRITE('C=');READLN(C);
        C. LUAS SEGITIGA                          Y1:=(A+B)+C;
                                                 WRITELN('Y1:=(A+B)+C;',Y1:9:2);
                                                  END;
PRAKTEK KE-8                                  2:
LATIHAN CASE … OF …                           BEGIN
                                                 WRITE('A=');READLN(A);
NAMA FILE : LAT17.PAS                            WRITE('B=');READLN(B);
PROGRAM CASEOF;                                  WRITE('C=');READLN(C);
USES CRT;                                         Y2:=(A+B)-C;
VAR                                              WRITELN('Y2:=(A+B)-C;',Y2:9:2);
 PIL:BYTE;                                        END;
                                               3:
A,B,C,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11      BEGIN
,Y12,Y13,Y14,Y15,Y16:REAL;                       WRITE('A=');READLN(A);
BEGIN                                            WRITE('B=');READLN(B);
   CLRSCR;                                       WRITE('C=');READLN(C);
                                                  Y3:=(A+B)/C;
  GOTOXY(10,2);WRITELN('MENU');                  WRITELN('Y3:=(A+B)/C;',Y3:9:2);
                                                  END;
GOTOXY(10,3);WRITELN('============='             4:
);                                            BEGIN
                                                 WRITE('A=');READLN(A);
GOTOXY(10,4);WRITELN('1.Y1=(A+B)+C');            WRITE('B=');READLN(B);
   GOTOXY(10,5);WRITELN('2.Y2=(A+B)-             WRITE('C=');READLN(C);
C');                                              Y4:=(A+B)*C;
                                                 WRITELN('Y4:=(A+B)*C;',Y4:9:2);
GOTOXY(10,6);WRITELN('3.Y3=(A+B)/C');             END;
                                               5:
GOTOXY(10,7);WRITELN('4.Y4=(A+B)*C');         BEGIN
   GOTOXY(10,8);WRITELN('5.Y5=(A-                WRITE('A=');READLN(A);
B)+C');                                          WRITE('B=');READLN(B);
   GOTOXY(10,9);WRITELN('6.Y6=(A-B)-             WRITE('C=');READLN(C);
C');                                              Y5:=(A-B)+C;
   GOTOXY(10,10);WRITELN('7.Y7=(A-               WRITELN('Y5:=(A-B)+C;',Y5:9:2);
B)/C');                                           END;
   GOTOXY(10,11);WRITELN('8.Y8=(A-             6:
B)*C');                                       BEGIN
                                                 WRITE('A=');READLN(A);
GOTOXY(10,12);WRITELN('9.Y9=(A/B)+C');           WRITE('B=');READLN(B);
                                                 WRITE('C=');READLN(C);
GOTOXY(10,13);WRITELN('10.Y10=(A/B)-              Y6:=(A-B)-C;
C');                                             WRITELN('Y6:=(A-B)-C;',Y6:9:2);
                                                  END;
GOTOXY(10,14);WRITELN('11.Y11=(A/B)/C'         7:
);                                            BEGIN
                                                 WRITE('A=');READLN(A);
GOTOXY(10,15);WRITELN('12.Y12=(A/B)*C'           WRITE('B=');READLN(B);
);                                               WRITE('C=');READLN(C);
                                                  Y7:=(A-B)/C;
GOTOXY(10,16);WRITELN('13.Y13=(A*B)+C            WRITELN('Y7:=(A-B)/C;',Y7:9:2);
');                                               END;
                                              8:
GOTOXY(10,17);WRITELN('14.Y14=(A*B)-          BEGIN
C');                                             WRITE('A=');READLN(A);
                                                 WRITE('B=');READLN(B);
GOTOXY(10,18);WRITELN('15.Y15=(A*B)/C'           WRITE('C=');READLN(C);
);                                                Y8:=(A-B)*C;
                                                 WRITELN('Y8:=(A-B)*C;',Y8:9:2);
GOTOXY(10,19);WRITELN('16.Y16=(A*B)*C'            END;
);                                             9:
   GOTOXY(10,20);WRITE('NOMOR                 BEGIN
PILIHAN?');READLN(PIL);                          WRITE('A=');READLN(A);
   CLRSCR;                                       WRITE('B=');READLN(B);
   CASE PIL OF                                   WRITE('C=');READLN(C);

                                     Halaman 14
     Y9:=(A/B)+C;                                      D.   V=S/T
     WRITELN('Y9:=(A/B)+C;',Y9:9:2);                   E.   A=S/TT
     END;                                              F.   F=MS/TT
   10:                                                 G.   E=MVV/2
  BEGIN
     WRITE('A=');READLN(A);                       2.MENU UNTUK MENGHITUNG
     WRITE('B=');READLN(B);                             H. LUAS LINGKARAN
     WRITE('C=');READLN(C);                             I. LUAS 4PERSEGIPANJANG
     Y10:=(A/B)-C;                                      J. LUAS SEGITIGA
     WRITELN('Y10:=(A/B)-C;',Y10:9:2);
     END;
    11:
  BEGIN
     WRITE('A=');READLN(A);                 PRAKTEK KE-9
     WRITE('B=');READLN(B);                 LATIHAN PROCEDURE …
     WRITE('C=');READLN(C);
     Y11:=(A/B)/C;
     WRITELN('Y11:=(A/B)/C;',Y11:9:2);      NAMA FILE : LAT22.PAS
     END;                                   PROGRAM prosedur;
    12:                                     USES CRT;
  BEGIN                                     VAR
     WRITE('A=');READLN(A);                 PIL:BYTE;
     WRITE('B=');READLN(B);                 A,B,C,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9:REAL;
     WRITE('C=');READLN(C);                 PROCEDURE S;
     Y12:=(A/B)*C;                          BEGIN
     WRITELN('Y12:=(A/B)*C;',Y12:9:2);      WRITE('A');READLN(A);
     END;                                   WRITE('B');READLN(B);
     13:                                    WRITE('C');READLN(C);
  BEGIN                                     Y1:=(A+B)+C;
     WRITE('A=');READLN(A);                 WRITELN('Y1:=(A+B)+C',Y1:9:2);
     WRITE('B=');READLN(B);                 END;
     WRITE('C=');READLN(C);                 PROCEDURE O;
     Y13:=(A*B)+C;                          BEGIN
     WRITELN('Y13:=(A*B)+C;',Y13:9:2);      WRITE('A');READLN(A);
     END;                                   WRITE('B');READLN(B);
   14:                                      WRITE('C');READLN(C);
  BEGIN                                     Y2:=(A+B)-C;
     WRITE('A=');READLN(A);                 WRITELN('Y2:=(A+B)-C',Y2:9:2);
     WRITE('B=');READLN(B);                 END;
     WRITE('C=');READLN(C);                 PROCEDURE L;
     Y14:=(A*B)-C;                          BEGIN
     WRITELN('Y14:=(A*B)-C;',Y14:9:2);      WRITE('A');READLN(A);
     END;                                   WRITE('B');READLN(B);
        15:                                 WRITE('C');READLN(C);
        BEGIN                               Y3:=(A+B)/C;
     WRITE('A=');READLN(A);                 WRITELN('Y3:=(A+B)/C',Y3:9:2);
     WRITE('B=');READLN(B);                 END;
     WRITE('C=');READLN(C);                 PROCEDURE E;
     Y15:=(A*B)/C;                          BEGIN
     WRITELN('Y15:=(A*B)/C;',Y15:9:2);      WRITE('A');READLN(A);
     END;                                   WRITE('B');READLN(B);
     16:                                    WRITE('C');READLN(C);
  BEGIN                                     Y4:=(A+B)*C;
     WRITE('A=');READLN(A);                 WRITELN('Y4:=(A+B)*C',Y4:9:2);
     WRITE('B=');READLN(B);                 END;
     WRITE('C=');READLN(C);                 PROCEDURE H;
     Y15:=(A*B)*C;                          BEGIN
     WRITELN('Y15:=(A*B)*C;',Y15:9:2);      WRITE('A');READLN(A);
     END;                                   WRITE('B');READLN(B);
  ELSE                                      WRITE('C');READLN(C);
  BEGIN                                     Y5:=(A-B)+C;
  END;                                      WRITELN('Y5:=(A-B)+C',Y5:9:2);
  END;                                      END;
                                            PROCEDURE U;
END.                                        BEGIN
                                            WRITE('A');READLN(A);
TUGAS KE 8                                  WRITE('B');READLN(B);
BUATLAH PROGRAMNYA:                         WRITE('C');READLN(C);
   1.MENU UNTUK MENGHITUNG                  Y6:=(A-B)-C;

                                     Halaman 15
WRITELN('Y6:=(A-B)-C',Y6:9:2);            BEGIN
END;                                      D;
PROCEDURE D;                              END;
BEGIN                                     8:
WRITE('A');READLN(A);                     BEGIN
WRITE('B');READLN(B);                     I;
WRITE('C');READLN(C);                     END;
Y7:=(A-B)/C;
WRITELN('Y7:=(A-B)/C',Y7:9:2);            9:
END;                                      BEGIN
PROCEDURE I;                              N;
BEGIN                                     END;
WRITE('A');READLN(A);                     ELSE
WRITE('B');READLN(B);                     BEGIN
WRITE('C');READLN(C);                     END;
Y8:=(A-B)*C;                              END;
WRITELN('Y8:=(A-B)*C',Y8:9:2);            END.
END;
PROCEDURE N;
BEGIN                                     NAMA FILE : LAT23.PAS
WRITE('A');READLN(A);                     PROGRAM PROCEDURE_KE3;
WRITE('B');READLN(B);                     USES CRT;
WRITE('C');READLN(C);                     VAR
Y9:=(A/B)+C;                              PIL : BYTE;
WRITELN('Y9:=(A*B)+C',Y9:9:2);            R,L,T,LUAS : REAL;
END;                                      PROCEDURE LUAS_LINGKARAN;
BEGIN                                     BEGIN
CLRSCR;                                   WRITE(„JARI-JARI : „);READLN( R );
GOTOXY(10,2);WRITELN('MENU');             LUAS := PI*R*R;
GOTOXY(10,3);WRITELN('=============       WRITELN(„LUAS LINGKARAN : „,LUAS:9:2);
======');                                 END;
GOTOXY(10,4);WRITELN('1.Y1=(A+B)+C');     PROCEDURE LUAS_SEGITIGA;
GOTOXY(10,5);WRITELN('2.Y2=(A+B)-C');     BEGIN
GOTOXY(10,6);WRITELN('3.Y3=(A+B)/C');     WRITE(„PANJANG ALAS : „);READLN( L );
GOTOXY(10,7);WRITELN('4.Y4=(A+B)*C');     WRITE(„TINGGI : „);READLN( T );
GOTOXY(10,8);WRITELN('5.Y5=(A-B)+C');     LUAS := 0.5*L*T;
GOTOXY(10,9);WRITELN('6.Y6=(A-B)-C');     WRITELN(„LUAS SEGITIGA : „,LUAS:9:2);
GOTOXY(10,10);WRITELN('7.Y7=(A-B)/C');    END;
GOTOXY(10,11);WRITELN('8.Y8=(A-B)*C');    PROCEDURE
GOTOXY(10,12);WRITELN('9.Y9=(A*B)+C');    LUAS_4_PERSEGIPANJANG;
GOTOXY(10,13);WRITELN('Pilihan            BEGIN
Anda?');READLN(PIL);                      WRITE(„PANJANG : „);READLN( T );
CLRSCR;                                   WRITE(„LEBAR : „);READLN( L );
CASE PIL OF                               LUAS := T*L;
1:                                        WRITELN(„LUAS 4 PERSEGI PANJANG :
BEGIN                                     „,LUAS:9:2);
S;                                        END;
END;                                      BEGIN
2:                                        CLRSCR;
BEGIN                                     GOTOXY(10,2);WRITELN(„MENU „);
O;                                        GOTOXY(10,4);WRITELN(„=============
END;                                      ====== „);
3:                                        GOTOXY(10,6);WRITELN(„1. MENGHITUNG
BEGIN                                     LUAS LINGKARAN„);
L;                                        GOTOXY(10,8);WRITELN(„2. MENGHITUNG
END;                                      LUAS SEGITIGA„);
4:                                        GOTOXY(10,10);WRITELN(„3.
BEGIN                                     MENGHITUNG               LUAS         4
E;                                        PERSEGIPANJANG„);
END;                                      GOTOXY(10,12);WRITE(„NOMOR PILIHAN
5:                                        ?„);READLN(PIL);
BEGIN                                     CLRSCR;
H;                                        CASE PIL OF
END;                                      1:
6:                                        BEGIN
BEGIN                                     LUAS_LINGKARAN;
U;                                        END;
END;                                      2:
7:                                        BEGIN

                                   Halaman 16
LUAS_SEGITIGA;                              BEGIN
END;                                        CLRSCR;
3:                                          WRITE(„NILAI KE 1 : „);READLN(X);
BEGIN                                       WRITE(„NILAI KE 2 : „);READLN(Y);
LUAS_4_PERSEGIPANJANG;                      WRITELN(X, ‟ + ‟ , Y, ‟ = ‟ , JUMLAH(X,Y,C));
END;                                        WRITELN(X, ‟ * ‟ ,Y, ‟ = ‟ , C);
ELSE                                        END.
BEGIN
WRITELN(„NOMOR PILIHAN HANYA 1, 2,          NAMA FILE : LAT26.PAS
3‟);                                        PROGRAM FUNCTION_KE3;
WRITELN(„JANGAN           NGAWUR            VAR
AAAAAAAAH‟);                                A,B : REAL;
END;                                        FUNCTION PANGKAT(X , N : REAL);REAL;
END;                                        BEGIN
END.                                        PANGKAT := EXP(LN(X)*N);
                                            END;
TUGAS KE 9                                  BEGIN
BUATLAH PROGRAMNYA           GABUNGAN       WRITE(„NILAI AKAN DIPANGKATKAN :
MENU DAN PROSEDUR                           „);READLN(A);
   1. MENU:                                 WRITE(„DIPANGKATKAN       DENGAN     :
         A. A= X/Y                          „);READLN(B);
         B. B=X*Y                           WRITELN(A:9:3, ‟ PANGKAT ‟ ,B:9:3, ‟
         C. C=X-Y                           ADALAH ‟, PANGKAT(A,B):9:3);
         D. D=X+Y                           REPEAT UNTIL KEYPRESSED;
                                            END.
   2. MENU:
        A.    V = S /T                      NAMA FILE : LAT27.PAS
        B.    A=S/TT                        PROGRAM FUNGSI_MAT;
        C.    F=MS/TT                       USES CRT
        D.    E=MVV/2                       VAR
                                            X,Y,X,P : REAL;
                                            FUNCTION MUTLAK(X : REAL): REAL;
                                            BEGIN
PRAKTEK KE 10                               IF X < 0 THEN X := -X; ABS := X;
LATIHAN FUNCTION …                          END;
                                            FUNCTION EKPONEN(A: REAL);REAL;
                                            BEGIN
NAMA FILE : LAT24.PAS                       EKPONEN:= EXP(X);
PROGRAM FUNCTION_KE1;                       END;
USES CRT
VAR                                         FUNTION LON(A:REAL):REAL;
NILAI1,NILAI2 : REAL;                       BEGIN
FUNCTION TERBESAR(X,Y : REAL): REAL;        LON := LN(X);
BEGIN                                       END;
IF X > Y THEN
TERBESAR := X                               FUNCTION LOGARITMA(A:REAL):REAL;
ELSE                                        BEGIN
TERBESAR := Y;                              LOGARITMA := LN(X)/LN(10);
END;                                        END;
BEGIN                                       BEGIN
CLRSCR;                                     CLRSCR;
WRITE(„NILAI          PERTAMA           :   WRITE(„BILANGAN YANG DIMUTLAKAN :
„);READLN(NILAI1);                          „);READLN(X);
WRITE(„NILAI KEDUA : „);READLN(NILAI2);     WRITE(„BILANGAN                   YANG
WRITELN(„NILAI TERBESAR ADALAH :            DIEXPONENSIALKAN : „);READLN(Y);
„,TERBESAR(NILAI1,NILAI2):9;3);             WRITE(„BILANGAN YANG DILOGARITMA
REPEAT UNTIL KEYPRESSED;                    NATURALKAN : „);READLN(Z);
END.                                        WRITE(„BILANGAN                   YANG
                                            DILOGARITMAKAN : „);READLN(P);
NAMA FILE : LAT25.PAS                       WRITELN(„NILIA
PROGRAM FUNCTION_KE2;                       MUTLAK‟,X,‟ADALAH:‟,MUTLAK(X);
USES CRT;                                   WRITELN(„NILIA
VAR                                         EKPONENSIAL‟,Y,‟ADALAH:‟,EKPONEN(X);
X,Y,Z : INTEGER;                            WRITELN(„NILIA LN‟,Z,‟ADALAH:‟,LON(Z);
FUNCTION JUMLAH(A,B,C : REAL);REAL;         WRITELN(„NILIA
BEGIN                                       LOGARITMA‟,P,‟ADALAH:‟,LOGARITMA(P);
JUMLAH := A+B;                              REPEAT UNTIL KEYPRESSED;
C := A*B;                                   END.
END;

                                     Halaman 17
                                               WRITELN(KALIMAT);
PROGRAM TRIGONOMETRI;                          END.
VAR
X : REAL;                                      NAMA FILE : LAT29.PAS
                                               PROGRAMHAPUS_KAR;
FUNCTION F_SINUS(A: REAL);                     USES CRT;
BEGIN                                          VAR
F_SINUS := SIN(X/57.3);                        BAHASA : STRING[12];
END;                                           URUTAN,POSISI : INTEGER;
FUNCTION F_COSINUS(A: REAL);                   BEGIN
BEGIN                                          BAHASA := „TURBO PASCAL‟;
F_COSINUS := COS(X/57.3);                      FOR URUTAN := 1 TO 12 DO
END;                                           BEGIN
                                               POSISI := 14 – URUTAN;
FUNCTION F_COSECAN(A: REAL);                   DELETE(BAHASA,POSISI,1);
BEGIN                                          WRITE(BAHASA);
F_COSECAN := 1/COS(X/57.3);                    END;
END;                                           REPEAT UNTIL KEYPRESSED;
FUNCTION F_SECAN(A: REAL);                     END.
BEGIN
F_SECAN := 1/SIN(X/57.3);                      NAMA FILE : LAT30.PAS
END;                                           PROGRAM INSET_KAR;
BEGIN                                          USES CRT;
CLRSCR;                                        VAR
WRITE(„SUDUT : „);READLN(X);                   NAMA : STRING[13];
WRITELN(„SINUS         :     „,X,‟ADALAH       BEGIN
:‟,F_SINUS(X):9:2);                            CLRSCR;
WRITELN(„COSINUS         :   „,X,‟ADALAH       NAMA := „TURBOPASCAL‟;
:‟,F_COSINUS(X):9:2);                          WRITELN(NAMA);
WRITELN(„COSECAN          :  „,X,‟ADALAH       INSERT(„=‟,NAMA,6);
:‟,F_COSECAN(X):9:2);                          WRITELN(NAMA);
WRITELN(„SECA         :      „,X,‟ADALAH       REPEAT UNTIL KEYPRESSED;
:‟,F_SECAN(X):9:2);                            END.
REPEAT UNTILKEYPRESSED;
END.                                           NAMA FILE : LAT31.PAS
                                               PROGRAM STR;
                                               USES CRT;
TUGAS KE 10                                    VAR
BUATLAH PROGRAM         MENGGUNAKAN            NILAI1,NILAI2 : INTEGER;
FUNCTION:                                      X1,X2 : STRING[5];
Y1 = ( A + B ) + C                             BEGIN
Y2 = ( A / B ) + C                             CLRSCR;
Y3 = ( A - B ) + C                             NILAI1 := 1234;
Y4 = ( A * B ) + C                             NILAI2 := 56789;
Y5 = ( A + B ) + C                             WRITELN(NILAI1,NILAI2);
Y6 = ( A + B ) / C                             STR(NILAI1:4,X1);
Y7 = ( A + B ) - C                             STR(NILAI2:4,X2);
Y8 = ( A + B ) * C                             WRITELN(X1+X2);
                                               REPEAT UNTIL KEYPRESSED;
                                               END.
PRAKTEK KE 11
OPERASI STRING                                 PROGRAM DEMO_HURUF;
                                               USES CRT,DOS;
                                               VAR
NAMA FILE : LAT28.PAS                          NAMA : STRING[50];
PROGRAM JUM_KAR;                               HURUF :STRING;
USES CRT;                                      BUFLEN,I,J,PANJANG,TENGAH : INTEGER;
CONST                                          BEGIN
JENIS = „BAHASA‟;                              CLRSCR;
NAMA = „TURBO PASCAL‟;                         BUFLEN := 50;
VAR                                            WRITE('NAMA ANDA ? ');READLN(NAMA);
SIFAT : STRING[10];                            PANJANG := LENGTH(NAMA);
KALIMAT       : STRING[80];                    TENGAH := 40-PANJANG DIV 2;
                                               CLRSCR;
BEGIN                                          FOR I := 1 TO PANJANG DO
CLRSCR;                                        BEGIN
SIFAT := „TERSTRUKTUR‟;                        HURUF := COPY(NAMA,I,1);
KALIMAT := JENIS+‟ „ +NAMA+‟        „    +     FOR J := 80 DOWNTO TENGAH + I DO
„MERUPAKAN‟+JENIS+‟ „ +SIFAT;                  BEGIN

                                        Halaman 18
GOTOXY(J,10);                                Larik atau record harus dikenalkan terlebih
WRITELN(HURUF,' ');DELAY(600);               dahulu kepada computer oleh anda dengan
END;                                         cara:
END;
REPEAT UNTIL KEYPRESSED;
END.                                         Var
                                             X : array[1..100] of byte;
NAMA FILE : LAT33.PAS
PROGRAM IO;                                  Keterangan:
USES CRT;                                    X : nama larik
VAR                                          1..100 : tipe indek
N, I, FAKTORIAL : INTEGER;                   Byte : tipe dari larik
HIO : INTEGER;
BEGIN                                        Deklarasi array:
CLRSCR;                                      X[1] := 1;
REPEAT                                       X[2] := 2;
{$I-}                                        X[3] := 3;
WRITE(„BERAPA         FAKTORIAL     :        X[4] := 4;
„);READLN(N);
{$I+}
HIO := IORESULT;                             NAMA FILE : LAT35.PAS
IF HIO <> 0 THEN                             {menentukan bilangan prima sampai dengan
WRITELN(„DATA       YANG   DIMASUKAN         1000}
SALAH,ULANGI‟);
UNTIL HIO = 0;                               Program larik1;
FAKTORIAL := 1;                              uses wincrt;
FOR I := 2 TO N DO FAKTORIAL :=              Var
FAKTORIAL*1;                                 Batas:real;
WRITELN;                                     I,j,jumlah:word;
WRITE(N,‟FAKTORIAL = „,FAKTORIAL);           Prima:array[1..1000] of char;
END.                                         begin
                                             batas := sqrt(1000);
NAMA FILE : LAT34.PAS                        jumlah := 0;
PROGRAM MENUNGGU;                            writeln('Bilangan prima s.d 1000');
USES CRT;                                    writeln;
PROCEDURE T_ENTER;                           for i := 2 to 1000 do
BEGIN                                        begin
WRITELN(„TEKAN        SEMBARANG              if prima[i] <> '*' then
TOMBOL‟);READLN;                             begin
END;                                         write(i:5);
PROCEDURE T_SEMBARANG;                       jumlah:=jumlah+1;
BEGIN                                        if i < batas then
WHILE NOT KEYPRESSED DO                      begin
WRITELN(„TEKAN        SEMBARANG              j := i;
TOMBOL‟);                                    while j < 1000 do
END.                                         begin
BEGIN                                        j:=j+i;
CLRSCR;                                      prima[j] := '*';
T_ENTER;                                     end;
T_SEMBARANG;                                 end;
END.                                         end;
                                             end;
                                             writeln;
TUGAS KE 11                                  writeln('ada = ',jumlah);
BUATLAH PROGRAMNYA:                          end.
   1. LIHAT   CONTOH      LAT29.PAS
      RUBAHLAH KATA TURBO PASCAL
      MENJADI NAMA ANDA                      NAMA FILE : LAT36.PAS
   2. LIHAT   CONTOH      LAT30.PAS          PROGRAM LARIK2;
      GUNAKAN TITIK DAN NAMA ANDA            program larik2;
                                             uses wincrt;
PRAKTEK KE 12                                var
LARIK                                        i,n : byte;
                                             total,rata,sigma,sd : real;
Larik atau record bertugas menangani data-   x : array[byte] of real;
data dalam satu klas yang sama.Contoh
dalam satu kelas anda terdapat nama siswa,   begin
jenis kelamin, nilai, hobi dan sebagainya.   clrscr;
                                             write('jumlah data(mak 255) ? ');readln(n);

                                      Halaman 19
writeln;                                             JAWABSOAL[1]:=NILAIJAWAB[2];
                                                     END;
total := 0;
for i := 1 to n do                                   IF UPCASE(JAWAB) = NILAIHURUF[4]
begin                                                THEN
write('nilai ke',i,'?');readln(x[i]);                BEGIN
total := total + x[i];                               JAWABSOAL[1]:=NILAIJAWAB[1];
end;                                                 END;

rata := total/n;                                     IF UPCASE(JAWAB) = NILAIHURUF[5]
sigma := 0;                                          THEN
for i := 1 to n do                                   BEGIN
sigma := sigma +sqr(x[i]-rata);                      JAWABSOAL[1]:=NILAIJAWAB[1];
sd := sqrt (sigma/n);                                END;
writeln;
writeln('jumlah data : ',n:7);                       JUMLAHNILAI:=JAWABSOAL[1];
writeln('total      : ',total:7:2);
writeln('rata-rata     :',rata:7:2);                 WRITELN(' HASIL PERIKSA            ');
writeln('standar deviasi :',sd:7:2);                 WRITELN(JUMLAHNILAI);
                                                     END.
end.
                                                     Nama file lat38.pas
Nama file lat37.pas                                  PROGRAM LARIK4;
PROGRAM LARIK3;                                      USES WINCRT;
USES WINCRT;                                         TYPE X = STRING[7];
CONST                                                CONST
NILAIHURUF : ARRAY[1..5] OF CHAR =                   FAKTORBIN : ARRAY[1..12] OF BYTE =
('A','B','C','D','E');                               (0,3,3,6,1,4,6,2,5,0,3,5);
JAWABSOAL:ARRAY[1..10]              OF               HARI      :    ARRAY[0..8]  OF     X   =
BYTE=(1,2,3,4,5,6,7,8,9,10);                         („MINGGU‟,‟SENIN‟,‟SELASA‟,‟RABU‟,‟KAMI
NILAIJAWAB:ARRAY[1..2] OF BYTE=(0,1);                S‟,‟JUMAT‟,‟SABTU‟);
                                                     VAR
VAR                                                  I : WORD;
I : WORD;                                            NAMA : STRING[255];
JUMLAHNILAI : INTEGER;                               J1,J2,J3,J4 : INTEGER;
JAWAB:CHAR;                                          TANGGAL,BULAN,TAHUN : INTEGER;
                                                     BEGIN
                                                     CLRSCR;
BEGIN                                                WRITE(„TANGGAL ? „);READLN(TANGGAL);
CLRSCR;                                              WRITE(„BULAN1..12 ? „);READLN(BULAN);
WRITELN('SOAL KE - 1');                              WRITE(„TAHUN ? „);READLN(TAHUN);
WRITELN('SEBUAH BENDA MELAKUKAN                      IF TAHUN > 1900 THEN
GERAK GLB DENGAN KECEPATAN 10 M/S                    TAHUN := TAHUN – 1900;
');                                                  J1 := TRUNC(TAHUN*365.25);
WRITELN('DALAM WAKTU 10 DETIK.                       J2 := J1+FAKTORBLN(BULAN);
TENTUKAN JARAK YANG DITEMPUH ?                       IF (TAHUN/4=INT(TAHUN/4)) AND (BULAN
');                                                  < 3) THEN J2 := J2-1;
WRITELN('A. 1 M B. 10 M C. 100 M D. 0.1              J3 := J2+TANGGAL;
M E. 0.01 M     ');                                  J4 := TRUNC(FRAC(J3/7)*0);
WRITELN('                                            WRITELN;
');                                                  WRITELN(„HARI ITU :‟,HARI[J4]);
WRITE('JAWABAN ? ');READLN(JAWAB);                   END.

                                                     TUGAS KE 12
IF UPCASE(JAWAB) = NILAIHURUF[1]                     BUATLAH PROGRAMNYA
THEN                                                 Y1 = ( A + B ) + C
BEGIN                                                Y2 = ( A / B ) + C
JAWABSOAL[1]:=NILAIJAWAB[1];                         Y3 = ( A * B ) + C
END;                                                 Y4 = ( A - B ) + C

IF UPCASE(JAWAB) = NILAIHURUF[2]
THEN                                                 PRAKTEK KE 13
BEGIN                                                LARIK DIMENSI DUA
JAWABSOAL[1]:=NILAIJAWAB[1];
END;                                                 Penulisan larik dimensi banyak               yang
                                                     dibolehkan:
IF UPCASE(JAWAB)               =    NILAIHURUF[3]    Cara1:
THEN                                                 Var
BEGIN                                                Table : arra[1..3] of array[1..2] of byte;

                                              Halaman 20
                                                   Table : x;
Atau

Type                                               Nama file lat39.pas
X = array[1..3,1..2] of byte;                      {matrik [baris,kolom]}
Table : x;                                         Program matrik1;
                                                   Uses wincrt;
Atau                                               Var
                                                   Table : arra[1..3,1..2] of byte;
Type                                               I,j : byte;
Baris = 1..3;                                      Bagin
X = array[baris,1..2] of byte;                     Clrscr;
Var                                                Table[1,1] := 1;
Table : x;                                         Table[1,2] := 2;
                                                   Table[2,1] := 3;
Atau                                               Table[2,2] := 4;
                                                   Table[3,1] := 5;
Type                                               Table[3,2] := 6;
Baris = 1..3;                                      For i: 1 to 3 do
Kolom = 1..2;                                      Begin
X = array[baris,kolom] of byte;                    For j:= 1 to 2 do
Var                                                Write(table[I,j]:10);
Table : x;                                         Writeln;
                                                   End;
Atau                                               End.

                                                   Nama file lat40.pas
Type                                               {perkalian matrik}
Baris = 1..3;                                      Program matrik2;
Kolom=1..2;                                        Uses wincrt;
X = array[baris] of array[kolom] of byte;          Type
Var                                                Larik = array[1..25,1..25] of real;
Table : x;                                         Var
                                                   I,J,J : byte;
Atau                                               M,N,L : byte;
                                                   A,B,C : larik;
Type                                               Begin
Karikkolom = array[1..2] of byte;                  Clrscr;
X = array[1..3] of larik kolom;                    Write(„baris matrik pertama ?‟);readln(M);
Var                                                Write(„kolom matrik pertama/baris matrik
Table : x;                                         kedua ?‟);readln(N);
                                                   Write(„kolom matrik kedua ? „);readln(L);
Atau                                               Writeln;
                                                   Writeln(„‟Matrik yang pertama:‟);
Type                                               For I := 1 to M do
Larikkolom=array[1..2] of byte;                    Begin
Var                                                For j:= 1 to N do
Table : array[1..3] of larikkolom;                 Begin
                                                   Write(„nilai[„,I,‟,‟,j,‟] ? „);readln(a[I,j]);
Atau                                               End;
                                                   Writeln;
Type                                               End;
Baris=1..3;
Kolom=1..2;                                        Writeln(„matrik yang kedua‟);
Larikkolom = array[kolom] of byte;                 For i:= 1 to n do
Var                                                Begin
Table : array[baris] of larikkolom;                For j:= 1 to L do
                                                   Begin
Atau                                               Write(„nilai[„,I,‟,‟,j,‟]?‟);readln(b[I,j]);
                                                   End;
Const                                              Writeln;
Awal =1;                                           End;
Jumlahbaris=3;
Jumlahkolom = 2;                                   For i:= 1 to n do
Type                                               Begin
X                                          =       For j:= 1 to n do
array[awal..jumlahbaris,awal..jumlahkolom] of      Begin
byte;                                              C[I,j] := 0;
Var                                                For k := 1 to L do

                                            Halaman 21
C[I,j] := c[I,j] + a[I,k]*b[k,j];                       Uses wincrt;
End;                                                    Type
Clrscr;                                                 Tipelarik = string[20];
Writeln(„hasil dari perkalian matrik‟);                 Larikurut = array[1..1000] of tipelarik;
Writeln;                                                Procedure qsort(var x : larikurut; bawah,atas :
For i:= 1 to n do                                       word);
Begin                                                   Var
For j:= 1 to L do write(c[I,j]:9:2);                    I,j : word;
Writeln;                                                Sementara : tipelarik;
End;                                                    Begin
End.                                                    While atas > bawah do
                                                        Begin
Nama file lat41.pas                                     I := bawah;
Program larik5;                                         J := atas;
Uses wincrt;                                            Sementara := x[bawah];
Type                                                    While i< j do
Tipelarik = word;                                       Begin
Larik = array[1..8] of tipelarik;                       While x[j] > sementara do
Peocedure       carianu(x:larik;      cari:tipelarik;   J := j-1;
bawah,atas:word; var urutketemu:word);                  X[i] := x[j];
Var                                                     While (i<j) and (x[i] <= sementara) do
Tengeh : word;                                          I := I + 1;
Begin                                                   X[j] := x[i];
If bawah > atas then                                    End;
Urut urutketemu := 0
Else                                                    X[i] := sementara;
Begin                                                   Qsort(x,bawah,i-1);
Tengah := (bawah +atas) div 2;                          Bawah := I + 1;
If cari = x[tengah] then                                End;
Urutketemu := tengah                                    End;
Else
If cari < x[tengah] then                                Var
Carianu(x,cari,bawah,tengah-1,urutketemu)               Nama : larikurut;
Else                                                    N,I : word;
Carianu(x,cari,tengah+1,atas,urutketemu);               Begin
End;                                                    Write(„jumlah data : „);readln(n);
End;                                                    Writeln(„Masukan datanya‟);
Type                                                    For I := 1 to n do
Stringnama = string[20];                                Begin
Const                                                   Write(„Data ke-‟,I,‟?‟);readln(nama[i]);
Nomormhs : larik(1,2,3,4,5,6,7,8);                      End;
Namamhs:array[1..8]                                of   Qsort(nama,1,n);
stringnama=(„A‟,‟B‟,‟C‟,‟D‟,‟E‟,‟F‟,‟G‟,‟H‟);           Writeln;
Var                                                     Writeln(„data sudah di urut‟);
Cari : word;                                            For I := 1 to n do
Ketemu : word;                                          Write(nama[i]);
Lagi : char;                                            End.
Begin
Lagi := „Y‟;
While upcase(lagi)=‟Y‟ do
Begin                                                   TUGAS KE 13
Clrscr;                                                 BUATLAH       PROGRAMNYA        UNTUK
]write(nomor siswa ?‟);readln(cari);                    PENJUMLAHAN,            PENGURANGAN,
Writeln;                                                PEMBAGIAN, PERKALIAN DARI MATRIK
Carianu(nomormhs,cari,1,8,ketemu);                      BERIKUT:
If ketemu = 0 then                                         1. A+B DAN A + C DAN B + C
Writeln(„tidak ditemukan‟)                                 2. A X B DAN A X B DAN B X C
Else                                                       3. A – B DAN A – C DAN B – C
Begin                                                      4. A / B DAN A / B DAN B / C
Writeln(„nomor siswa :‟,nomormhs[ketemu]);
Writeln(„nama siswa :‟,namamhs[ketemu]);
End;
Writeln;                                                A           2    4
Write(„Cari lagi(y/t) ? „); readln(lagi);                           3    5
End;                                                                     5
End.

Nama file lat42.pas                                     B           4    4
Program larik6;                                                     5    5
                                                                         5
                                                Halaman 22
                                                    For I := 1 to jumlahbrg do
                                                    Begin
                                                    With barang[i] do
C           6    4                                  Begin
            7    5                                  Totalunit := unitbrg[1]+unitbrg[2]+unitbrg[3];
                 5                                  Total1 := total1 + unitbrg[1];
                                                    Total2 := total2 + unitbrg[2];
                                                    Total3 := total3 + unitbrg[3];
PRAKTEK KE 14                                       Totaltotal := totaltotal + totalunit;
RECORD                                              Write(namabrg:15);
Record hampIr sama dengan larik                     Writeln(unitbrg[1]:7,
                                                    Unitbrg[2]:10,
Nama file lat43.pas                                 Unitbrg[3]:10,
Program record1;                                    Totalunit:10);
Uses crt;                                           End;
Type                                                End;
Hasil = record                                      Writeln;
Jari : real;
Keliling : real;                                    Writeln(„total :‟,total1:10,
Luas : real;                                        Total2:10,total3:10,
End;                                                Totaltotal:10);
Var                                                 End.
Lingkaran : hasil;                                  Nama file lat45.pas
Begin                                               Program record4;
Write(„jari-jari : „ );readln(lingkaran.jari);      Uses wincrt;
Lingkaran.keliling:=2*3.14*lingkaran.jari;          Type
Lingkaran.luas := 3.14*sqr(lingkaran.jari);         Pkar = ^ckar;
Writeln(„keliling               lingkaran       :   Ckar= record
„,lingkaran.keliling:7:2);                          Kode : string[5];
Writeln(„luas lingkaran :‟,lingkaran.luas:7:2);     Nama : string[25];
End.                                                Gaji : real;
                                                    End;
Nama file lat44.pas                                 Var
Program record2;                                    Datkar1,datkar2,
Uses wincrt;                                        Datkar3,datkar4,
Type                                                Datkar5 : pkar;
Databrg = record                                    Begin
Namabrg : string[15];                               Writeln(„masukan 5 buah data karyawan :‟);
Unitbrg : array[1..3] of byte;                      Writeln(„Karyawan ke-1‟);
End;                                                New(datkar1);
Var                                                 With datkar1^ do
Jumlahbrg,I,j : byte;                               Begin
Totalunit,total1,total2,total3,totaltotal : word;   Write(Kode karyawan ? „);readln(kode);
Barang : array[1..50] of barang;
Begin                                               Write(Nama karyawan ? „);readln(nama);
Write(„Jumlah barang : „ );readln(jumlahbrg);
For I := 1 to jumlahbrg do                          Write(Gaji karyawan ? „);readln(gaji);
Begin
Writeln;                                            End;
Writeln(„Barang ke „,i:2);
With barang[i] do                                   Writeln(„Karyawan ke-2‟);
Begin                                               New(datkar2);
Write(„nama barang ? „);readln(namabrg);            With datkar2^ do
For j := 1 to 3 do                                  Begin
Begin                                               Write(Kode karyawan ? „);readln(kode);
Write(„Unit ke‟,j:2,‟?‟);readln(unitbrg[j]);
End;                                                Write(Nama karyawan ? „);readln(nama);
End;
End;                                                Write(Gaji karyawan ? „);readln(gaji);
Writeln;
Writeln(„============================               End;
==========‟);
Writeln(„Unit‟);                                    Writeln(„Karyawan ke-3‟);
Writeln(„============================               New(datkar3);
======== „);                                        With datkar3^ do
Writeln(„nama barang u1 u2 u3 total „);             Begin
Writeln(; ----------------------------------- „);   Write(Kode karyawan ? „);readln(kode);
Total1 := 0; total2 := 0;
Total3 := 0; total4 := 0;                           Write(Nama karyawan ? „);readln(nama);

                                             Halaman 23
                                                Datanama[1]^.sesudah := 0;
Write(Gaji karyawan ? „);readln(gaji);          For I := 2 to n do
                                                Begin
End;                                            If            datanama[i]^.nama            >=
Writeln(„Karyawan ke-4‟);                       datanama[akhir]^.nama then
New(datkar4);                                   Begin
With datkar4^ do                                Datanama[i]^.sebelum:=akhir;
Begin                                           Datanama[akhir]^.sesudah:= I;
Write(Kode karyawan ? „);readln(kode);          Akhir := I;
                                                Datanama[akhir]^.sesudah:=0;
Write(Nama karyawan ? „);readln(nama);          End
                                                Else
Write(Gaji karyawan ? „);readln(gaji);          Begin
                                                J := datanama[akhir]^.sebelum;
End;                                            While           (datanama[i]^.nama         <=
Writeln(„Karyawan ke-5‟);                       datanama[j].nama) and (j>0) do         j   :=
New(datkar5);                                   datanama[j]^.sebelum;
With datkar5^ do                                If j = 0 then
Begin                                           Begin
Write(Kode karyawan ? „);readln(kode);          Datanama[awal]^.sebelum := I;
                                                Datanama[i]^.sesudah := awal;
Write(Nama karyawan ? „);readln(nama);          Awal := I;
                                                Datanama[awal]^.sebelum := 0;
Write(Gaji karyawan ? „);readln(gaji);          End
                                                Else
End;                                            Begin
Writeln(„Data karyawan‟);                       X := datanama[j]^.sesudah;
Writeln(„Kode Nama Gaji‟);                      Datanama[j]^.sesudah := I;
Writeln;                                        Datanama[x]^.sebelum := I;
With               datkar1^              do     Datanama[i]^.sebelum := j;
writeln(kode:5,nama:25,gaji:12:2);              Datanama[i]^.sesudah := x;
With               datkar2^              do     End;
writeln(kode:5,nama:25,gaji:12:2);              End;
With               datkar3^              do     End;
writeln(kode:5,nama:25,gaji:12:2);              End;
With               datkar4^              do     Procedure tanpilkan;
writeln(kode:5,nama:25,gaji:12:2);              Var
With               datkar5^              do     Posisi : integer;
writeln(kode:5,nama:25,gaji:12:2);              Begin
End.                                            Posisi := awal;
                                                While posisi > 0 do
Nama file lat46.pas                             Begin
Program record5;                                Write(datanama[posisi]^.nama);
Uses wincrt;                                    Posisi := datanama[posisi]^.sesudah;
Type                                            End;
Penunjuk = ^recnama;                            End;
Recnama = record                                Begin
Nama : string[15];                              Write(„jumlah data ?‟);readln(n);
Sebelum,sesudah : integer;                      Writeln;
End;                                            Masuk;
Var                                             Urutkan;
Datanama : array[1..1000] of penunjuk;          Writeln(„data setelah diurutkan‟);
Awal,akhir,I,j,m : integer;                     Tampilkan;
Procedure masuk;                                End.
Begin
For I := 1 to n do
Begin                                           TUGAS KE 14
New(datanama[i]);                               BUATLAH PROGRAMNYA:
Write(„nama ke‟,i:5,‟?‟);                       Y1 = ( A + B ) + C
Readln(datanama[i]^.nama);                      Y2 = ( A + B ) / C
End;                                            Y3 = ( A + B ) X C
End;                                            Y4 = ( A X B ) + C
Procedure urutkan;                              Y5 = ( A - B ) + C
Var                                             Y6 = ( A / B ) + C
X : integer;
Begin
Awal := 1;
Akhir := 1;
Datanama[1]^.sebelum := 0;

                                         Halaman 24
           GRAFIK                                 Fungsi        : menghasilkan nomor mode
        TEORI SINGKAT                             terendah dan tertinggi yang ada pada
                                                  penggerak grafik tertentu
 INITGRAPH                                       Sintak        : getmoderange(graphdriver :
Fungsi       : Menyiapkan sistem grafik           integer, var lomode,himode : integer);
Sintak       : Initgraph(dg,mg,drive);
Dg : driver grafik (CGA, VGA, )                    GETMAXX
Mg : mode grafik (0,1,2,3,4)                      Fungsi     : menghasilkan nilai nomor
                                                  kolom koordinat x paling kanan dari
 DETECTGRAPH                                     penggerak grafik
Fungsi      : Menentukan sendiri driver           Sintak     : getmaxx;
grafik
Sintak      :     detectgraph(     Var             GETMAXY
graphdriver,graphmode : integer);                 Fungsi     : menghasilkan nilai nomor
                                                  baris koordinat y paling kanan dari
 GRAPHRESULT                                     penggerak grafik
Fungsi     :     Menghasilkan       kode          Sintak     : getmaxy;
kesalahan untuk status grafik
Sintak     : graphresult;                          GETMAXCOLOR
                                                  Fungsi    : menghasilkan nilai warna
 GRAPHERRORMSG                                   maksimum dari penggerak grafik
Fungsi     :     Menggasilkan pesan               Sintak    : getmaxcolor;
kesalahan dalam bentuk string
Sintak     : grapherrormsg(kodeerror :             CLOSEGRAPH
integer);                                         Fungsi : menutup penggerak grafik
                                                  Sintak : closegraph;
 SETGRAPHMODE
Fungsi      : Mengubah system mode                 PUTPIXEL
grafik dan menghapus layar                        Fungsi       : menggambar sebuah titik
Sintak      :  setgraphmode(mode :                pada koordinat tertentu
integer);                                         Sintak       : putpixel(x,y : integer; warna
                                                  : word);
 GETGRAPHMODE                                     GETPIXEL
Fungsi      : Memperoleh status mode              Fungsi       : memperoleh nilai titik pada
grafik yang berlaku                               koordinat tertentu
Sintak      : getgraphmode;                       Sintak       : getpixel(x,y : integer);

 RESTORECRTMODE                                   LINE
Fungsi    :    Mengubah mode grafik               Fungsi        :    menggambar garis dari
menjadi mode karakter                             satu titik (x1,y1) ke titik (x2,y2)
Sintak    : restorecrtmode;                       Sintak        : line(x1,y1,x2,y2);

 GRAPHDEFAULTS                                    SETLINESTYLE
Fungsi     :    Merubah kondisi grafik            Fungsi       :   mengatur corak dan
kembali kesemula                                  ketebalan garis
Sintak     : graphdefaults;                       Sintak       : setlinestyle(corak, pola,
                                                  tebal : word);
 CLEARDEVICE
Fungsi :     Membersihkan momeri                   SETCOLOR
grafik                                            Fungsi   :          memberi      warna
Sintak : cleardevice;                             penggambaran dengan pelete yang
                                                  berlaku
 GETDRIVERNAME                                   Sintak   : setcolor(warna : word);
Fungsi    : menghasilkan string yang
menunjukan nama penggerak grafik                   GETCOLOR
Sintak    : getdrivername;                        Fungsi     : menghasilkan nilai warna
                                                  yang dilewatkan oleh prosedur setcolor
 GETMAXMODE                                      Sintak     : getcolor;
Fungsi   :     menghasilkan nomor
maksimum mode penggerak grafik                     SETWRITEMODE
Sintak   : getmaxmode;                            Fungsi    :          mengatur    cara
                                                  penggambaran grafik
 GETMODENAME                                     Sintak    :   setwritemode(writemode”
Fungsi     : menghasilkan string yang             integer);
menunjukan nama mode grafik dari suatu
penggerak yang aktif                               LINETO
Sintak     : getmodename;                         Fungsi      : menggambar garis dari titik
                                                  sedang aktif ke titik (x,y)
 GETMODERANGE                                    Sintak      : lineto(x,y : integer);

                                     Halaman 25
                                                        SETFILLPATTERN
 MOVETO                                               Fungsi        :    memilih pola pengisian
Fungsi          : memindahkan titik aktif ke           buatan sendiri
titik lain (x,y)                                       Sintak        :       setfillpattern(pola  :
Sintak          : moveto(x,y : integer);               fillpatterntype; warna : word);
                                                        GETFILLSETINGS
 MOVEREL                                              Fungsi        :    menghasilkan data-data
Fungsi        : memindahkan titik aktif ke             pola dan warna isian yang berlaku yang
titik lain yang berjarak relative terhadap             diatur oleh setfillstyle
titik aktif                                            Sintak        :getfillsetings(var fillinfo :
Sintak        : moverel(dx,dy : integer);              fillsettingstype);

 GETX                                                  RECTANGLE
Fungsi         : mendapatkan nilai titik x             Fungsi     : menggambar kotak dengan
dari titik aktif                                       corak dan warna yang aktif
Sintak         : getx;                                 Sintak     : rectangle(x1,y1,x2,y2)

 GETY                                                  BAR
Fungsi         : Mendapatkan nilai titik y             Fungsi      : membuat balok dengan
dari titik aktif                                       corak dan isian yang telah tersedia
Sintak         : gety;                                 Sintak      : bar(x1,y1,x2,y2 : integer);

 GETLINESETTINGS                                       BAR3D
Fungsi        : mendapatkan corak, pola,               Fungsi      : menggambar balok tiga
dan ketebalan garis yang diatur oleh                   dimensi dengan pola dan isian yang
setlinestyle                                           berlaku
Sintak        : getlinesettings(var infogaris          Sintak      : bar(x1,y1,x2,y2 : integer;
: linesettingstype);                                   depth : word; top : Boolean);

 LINEREL                                               FILLPOLY
Fungsi     : menggambar garis pada                     Fungsi      :      menggambar sekaligus
posisi yang berjarak relative dari titik               mengisi polygon
yang aktif                                             Sintak      : fillpoints(numpoints : word;
Sintak     : linerel(dx,dy : integer);                 var polypoints);

 GETFILLPATERN                                         GETARCCOORDS
Fungsi        :    menghasilkan data-data              Fungsi       :    menghasilkan koordinat
pola dan warna isian yang berlaku yang                 akibat perintah arc
diatur oleh setfillpatern                              Sintak       : getarccoords(var arccoord :
Sintak        : getfillpatern(var fillpatern :         arccoordstype);
fillpaterntype);
                                                        ELLIPSE
 SETFILLSTYLE                                         Fungsi       : menggambar bentuk elips
Fungsi        : memilih pola dan warna                 Sintak       : ellipse(x,y : integer; awal,
isian yang disediakan                                  akhir : word; jarix, jariy : word);
Sintak        : setfillstyle(pola : word;
warna : word);                                          DRAWPOLY
Pola:                                                  Fungsi      :     menggambar bentuk
0: emptyfill                                           sigibanyak dengan garis dan warna yang
1:solidfill                                            berlaku saat itu
2:linefill                                             Sintak      : drawpoly(numpoints : word;
3:ltslashfill                                          var polypoints);
4:slashfill
5:bkslashfill                                           CIRCLE
6:ltbkslashfill                                        Fungsi      : menmggambar lingkaran
7:hatchfill                                            dengan jari-jari tertentu dengan pusat
8:xhatchfill                                           berada di x,y
9:interleavefill                                       Sintak      : circle(x,y : integer,jari :
10:widedotfill                                         word);
11:closedotfill
12:usefill                                              FILLELLIPSE
                                                       Fungsi        :         menggambar ellipse
 FLOODFILL                                            dengan corak dan warna isian tertentu
Fungsi      : mengecat daerah tertutup                 Sintak        : fillellipse(x,y : integer; jarix,
dengan corak dan warna isian yang                      jariy : word);
sudah ditentukan
Sintak      : floodfill(x,y : integer; border           SECTOR
: word);                                               Fungsi    : menggambar dan mengisi
                                                       tembereng

                                          Halaman 26
Sintak         : sector(x,y : integer; awal,          Sintak        : setviewport(x1,y1,x2,y2   :
akhir, jarix, jariy : word);                          integer; clip : Boolean);

 SETTEXTSTYLE                                         CLEARVIEWPORT
Fungsi      : mengatur pemilihan huruf                Fungsi : membersihkan viewport
Sintak      :   settextstyle(font, arah,              Sintak : clearviewport;
ukuran : word);
                                                       GETVIEWSETTINGS
 SETTEXTJUSTIFY                                      Fungsi       :       mendapatkan      nilai
Fungsi  :   mengatur penempatan                       koordinat dan status dari viewport yang
huruf                                                 aktif
Sintak  : settextjustify(horiz, vert :                Sintak       :         getviewsettings(var
word);                                                viewport : viewporttype);

 OUTTEXT                                              SETBKCOLOR
Fungsi        : menempatkan huruf pada                Fungsi   :    mengubah warna latar
titik default                                         belakang
Sintak        : outtext(tek : string);                Sintak   : setbkcolor(warna : word);

 OUTTEXTXY                                            GETBKCOLOR
Fungsi    : menempatkan huruf pada                    Fungsi      : menghasilkan nilai warna
titik x,y                                             latar belakang yang berlaku saat itu
Sintak    : outtextxy(x,y : integer; teks :           Sintak      : getbkcolor;
string);
                                                       SETALLPALETTE
 TEXTHEIGHT                                          Fungsi  : mengubah semua warna
Fungsi : memperoleh ukuran tinggi                     palette
huruf                                                 Sintak  : setallpalette(var palette);
Sintak : textheight(teks : string);
                                                       REGISTERBGIFONT
 TEXTWIDTH                                           Fungsi    : mendaftarkan font kedalam
Fungsi : memperoleh ukuran lebar                      memori
huruf                                                 Sintak    :   registerbgifont(font   :
Sintak : textwidth(tek : string);                     pointer);

 GETASPECTRATIO                                       REGISTERBGIDRIVER
Fungsi    :    menghasilkan nilai-nilai               Fungsi     : mendaftarkan penggerak
untuk menentukan harga aspek rasio                    bgi kedalam memory
Sintak    : getaspectratio(aspx, aspy :               Sintak     : registerbgidriver
word);
                                                       INSTALLUSERFONT
 SETASPECTRATIO                                      Fungsi   : menginstal huruf baru
Fungsi  :   mengubah aspect ratio                     Sintak   : installuserfont(namafilefont :
default                                               string);
Sintak  : setaspectratio*aspx, aspy :
word);                                                 GETIMAGE
                                                      Fungsi       :   merekam gambar pada
 PIESLICE                                            suatu daerah memory buffers
Fungsi        :     menggambar sekaligus              Sintak       :   getimage(x1,y1,x2,y2 :
mengisi suatu irisan pie                              integer; var petabit);
Sintak        : pieslice(x,y : integer; awal,
akhir ,jari: word);                                    IMAGESIZE
                                                      Fungsi      : menghasilkan jumlah byte
 SETUSERCHARSIZE                                     dari suatu gambar pada posisi segiempat
Fungsi        : mengubah tinggi dan lebar             Sintak      : imagesize(x1,y1,x2,y2 :
huruf                                                 integer);
Sintak        :       setusercharsize(kalix,
bagix, kaliy, bagiy : word);                           PUTIMAGE
                                                      Fungsi      : meletakan gambar ke layar
 GETTEXTSETTINGS                                     Sintak      : putimage(x,y : integer; var
Fungsi       :    memperoleh nilai font,              petabit; penggambaran);
arah, ukuran, dan pointer huruf yang di               Penggambaran terdiri dari:
atur oleh settextstyle san settextjustify             0:copyput
Sintak       : gettextsetting(var infoteks :          1:xorpout
textsettingstype);                                    2:orput
                                                      3:andput
 SETVIEWPORT                                         4:notput
Fungsi    : mengatur letak viewport
dan mengatur sifatnya                                  ARC

                                         Halaman 27
Fungsi        :     menggambar lingkaran                BUATLAH PROGRAM BERIKUT:
terpotong                                               GRAFIK FUNGSI TRIGONOMETRI
Sintak        : arc(x,y : integer; awal, akhir,         A. SINUS
jari : word);                                           B. COSINUS
                                                        C. TANGEN
                                                        D. SECAN
PRAKTEK KE 15                                           E. COSECAN
MEMBUAT TITIK                                           F. COTANGEN
                                                        G. Y = 2X + X
                                                                 2
Program bintangku;                                      H. Y = 2X + X
Use crt,graph;                                          I. Y = 2X + SIN X
Var
Dg,mg,I,maxx,maxy : integer;
Warna : word;                                           PRAKTEK KE 16
Begin                                                   MEMBUAT GARIS
Dg := detect;
Initgraph(dg,mg,‟ ‟);                                   Program garis;
If graphresult <> grok then halt(1);                    Use crt,graph;
Maxx := getmaxx;                                        Var
Maxy := getmaxy;                                        Dg,mg,I,maxx,maxy
Warna := getmaxcolor;                                   X,x1,y1,x2,y2 : integer;
For I := 1 to 2000 do                                   Warna : word;
Putpixel(random(maxx)+1,random(maxy)                    Begin
+1,random(warna)+1);                                    Dg := detect;
Repeat until keypressed;                                Initgraph(dg,mg,‟ ‟);
Closegraph;                                             If graphresult <> grok then halt(1);
End.                                                    Maxx := getmaxx;
                                                        Maxy := getmaxy;
Program kelip;                                          Warna := getmaxcolor;
Uses crt,graph;                                         For I := 1 to 2000 do
Const                                                   Putpixel(random(maxx)+1,random(maxy)
Maxtitik=2000;                                          +1,random(maxcolor)+1);
Var                                                     Setwritemode(xorput);
Dg,mg,maxcolor,x,y                                      Setcolor(3);
Maxx,maxy,I : integer;                                  Y1 := 0;
Warna : word;                                           Y2 := maxy;
Titik : array[1..maxtitik] of pointtype;                For I := 1 to 2 do
Begin                                                   Begin
Dg := detect;                                           For x := 0 to maxx do
Initgraph(dg,mg,‟ „ );                                  Begin
If graphresult <> grok then halt(1);                    X1 := maxx-x;
Maxx := getmaxx;                                        X2 := x;
Maxy := getmaxy;                                        Line(x1,y1,x2,y2);
Maxcolor := getmaxcolor;                                End;
For I := 1 to maxtitik do                               Repeat until keypressed;
Begin                                                   End;
With titik[i] do                                        Closegraph;
Begin                                                   End.
X := random(maxx)+1;
y := random(maxy)+1;                                    Program gariske;
end;                                                    Use crt,graph;
end;                                                    Var
while not keypressed do                                 Dg,mg,I,maxx,maxy,acaky,yawal,x        :
begin                                                   integer;
for I := 1 to maxtitik do                               Warna : word;
begin                                                   Begin
with titik[i] do                                        Dg := detect;
putpixel(x,y,random(maxcolor)+1);                       Initgraph(dg,mg,‟ ‟);
end;                                                    If graphresult <> grok then halt(1);
for I := 1 to maxtitik do                               Maxx := getmaxx;
begin                                                   Maxy := getmaxy;
with titik[i] do                                        Yawal := maxy div 2;
putpixel(x,y,0);                                        X := 0;
end;                                                    Acaky := yawal;
end;                                                    Moveto(x,yawal);
closegraph;                                             For I := 0 to maxx div 2 do
end.                                                    Begin
                                                        Acaky := random(maxy)+1;
TUGAS KE 15                                             Inc(x,2);

                                           Halaman 28
Lineto(x,acaky);                                      Closegraph;
End;                                                  End.
Repeat until keypressed;
Closegraph;
End.                                                  TUGAS KE 16

                                                      GAMBAR 1
Program bendera;
Use crt,graph;
Var
Dg,mg,I,maxx,maxy,
X,y,setmaxy : integer;
Warna : word;
Begin
Dg := detect;
Initgraph(dg,mg,‟ ‟);
If graphresult <> grok then halt(1);
Maxx := getmaxx;
Maxy := getmaxy;
Setmaxy := maxy div 2;
Setcolor(1);
Settextjustify(centertext,centertext);
Settextstyle(triplexfont,horizdir,5);
Outtextxy(maxx        div   2,setmaxy     –
5,‟Benderaku‟);
Setwritemode(xorput);
Setlinestyle(solidln,0,normwidth);
For I := 1 to 2 do                                    GAMBAR 2
For x := 0 to maxx do
Begin
Moveto(x,setmaxy);
Setcolor(3);
Linerel(0,50);
Moveto(x,setmaxy – 1);
Setcolor(2);
Linerel(0,-50);
End;
Repeat until keypressed;
Closegraph;
End.

PROGRAM GARIS;                                        PRAKTEK KE 17
Use crt,graph;                                        MEMBUAT KOTAK
Var
Dg,mg,maxx : integer;                                 Program Kotak;
Coraklama : linesettingstype;                         Use crt,graph;
Procedure tunggu;                                     Var
Var                                                   Setmaxx,setmaxy,Dg,
Ch : char;                                            mg,I,maxcolor : integer;
Begin                                                 Warna : word;
Repeat until keypressed;                              Begin
Ch := readkey;                                        Dg := detect;
End;                                                  Initgraph(dg,mg,‟ ‟);
Begin                                                 If graphresult <> grok then halt(1);
Dg := detect;                                         setMaxx := getmaxx div 2;
Initgraph(dg,mg,‟ ‟);                                 setMaxy := getmaxy div 2;
If graphresult <> grok then halt(1);                  maxcolor := getmaxcolor;
Maxx := getmaxx;                                      for I := 0 to (setmaxy div 4) do
Setlinestyle(dashedln,0,thickwidth);                  begin
Line(0,1,maxx,1);                                     setcolor(random(maxcolor)+1);
Getlinesettings(coraklama);                           rectangle(setmaxx-i*6,setmaxy-
Tunggu;                                               i*4,setmaxx+i*6,setmaxy+i*4);
Setlinestyle(userbitln,$CCCC,normwidth);              end;
Line(0,7,maxx,7);                                     repeat until keypressed;
Tunggu;                                               closegraph;
With coraklama do                                     end.
Setlinestyle(linestyle,pattern,thickness);
Line(0,12,maxx,12);
Tunggu;                                               Program pilgaya;

                                         Halaman 29
Use crt,graph;                                           End;
Const                                                    Procedure demofill(pola:word; var keluar
Panahup = #72;                                           : char);
Pahandn = #80‟                                           Begin
Esc = #27;                                               If keluar = panahup then
Null = #00;                                              Begin
Var                                                      Dec(y,tinggitek+4);
Maxx,maxy,maxcolor,                                      If y <= 1 then
Lebartext,tinggitext,pilih,x,y : integer;                Begin
Ch,keluar : char;                                        Inc(y,tinggitek+4);
Simpanexit : pointer;                                    If y >= ((tinggitek+4)*pilih+4) then y := 1;
{$F+}                                                    End;
Procedure keluarprog;                                    Blok(x,y,lebartek,tinggitek+1);
Begin                                                    Setfillstyle(pola,2);
Exitproc := simpanexit;                                  Rectangle(lebartek+2,0,maxx, (maxy div
Closegraph;                                              2 + 44));
End;                                                     Floodfill(lebartek+3,1,maxcolor);
{$F-}                                                    Ch := redkey;
                                                         If ch = null then ch := readkey;
Procedure           blok(xx,yy,panjx,panjy   :           Keluar := ch;
integer);                                                Blok(x,y,lebartek,tinggitek+1);
Var                                                      End;
Ty,tx : integer;                                         Begin
Begin                                                    Simpanexit := exitproc;
Setcolor(maxcolor);                                      Exitproc := @keluarprog;
Setwritemode(xorput);                                    Init;
Setlinestyle(solidln,0,normwidth);                       Pilih := 0;
For ty := yy to (ty+panjy+1) do                          Keluar := #32;
Line(xx-1,ty,xx+panjx-1,ty);                             While keluar <> esc do
Setwritemode(copyput);                                   Begin
End;                                                     Case pilih of
Procedure init;                                          00:demofill(emptyfill,keluar);
Var                                                      01:demofill(solidfill,keluar);
Dg,mg : integer;                                         02:demofill(linefill,keluar);
Procedure tulis(kar : string);                           03:demofill(ltslashfill,keluar);
Begin                                                    04:demofill(slashfill,keluar);
Outtextxy(x,y,kar);                                      05:demofill(bkslashfill,keluar);
Inc(y,textheight(„H‟)+4);                                06:demofill(ltbkslashfill,keluar);
End;                                                     07:demofill(hatchfill,keluar);
Begin                                                    08:demofill(xhatchfill,keluar);
Dg := detect;                                            09:demofill(interleavefill,keluar);
Initgraph(dg,mg,‟ „ );                                   10:demofill(widedotfill,keluar);
If graphresult <> grok then                              11:demofill(closedotfill,keluar);
Halt(1);                                                 End;
Maxx := getmaxx;                                         If keluar = panahdn then
Maxy := getmaxy;                                         If pilih = 11 then pilih = 0
Maxcolor := getmaxcolor;                                 Else
X := 1; y := 1;                                          Inc(pilih);
Settextstyle(smallfont,horizdir,5);                      If keluar = panahup then
Tulis(„emptyfill‟);                                      If pilih = 0 then pilih := 11
Tulis(„solidfill‟);                                      Else
Tulis(„linefill‟);                                       Dec(pilih);
Tulis(„ltslashfill‟);                                    End;
Tulis(„slashfill‟);                                      End.
Tulis(„bkslashfill‟);
Tulis(„ltbkslashfill‟);
Tulis(„hatchfill‟);                                      Program pilpaterngaya;
Tulis(„xhatchfill‟);                                     Use crt,graph;
Tulis(„interleavefill‟);                                 Const
Tulis(„widedotfill‟);                                    Panahup = #72;
Lebartek:= textwidth(„interleavefill‟);                  Pahandn = #80‟
Tinggitek := textheight(„H‟);                            Esc = #27;
Settextjustify(centertext,bottomtext);                   Null = #00;
Settextstyle(smallfont,horizdir,4);                      Keloktipisver:
Setcolor(1);                                             fillpattentype($11,$22,$44,$88,$88,$44,$
Outtextxy(maxx               div       2,maxy-           22,$11);
textheight(„H‟),‟Gerakan Anak Panah                      Keloktebalver:
Kanan, kiri, Atas, Bawah, dan Esc „);                    fillpattentype($33,$66,$cc,$cc,$cc,$cc,$6
X := 1; y := 1;                                          6,$33);

                                            Halaman 30
Keloktipishor:                                           Tulis(„keloktebalver‟);
fillpattentype($18,$24,$42,$81,$18,$24,$                 Tulis(„keloktipishor‟);
42,$81);                                                 Tulis(„keloktebalhor‟);
Keloktebalhor:                                           Tulis(„inisialy‟);
fillpattentype($18,$7e,$c3,$81,$18,$7b,$                 Tulis(„tipistebalver‟);
c3,$81);                                                 Tulis(„tipistipisver‟);
inisialy:                                                Tulis(„lukuk‟);
fillpattentype($cc,$cc,$cc,$fc,$30,$30,$3                Tulis(„tipistebalhor‟);
0,$00);                                                  Tulis(„tipistipishor‟);
tipistebalver:                                           Tulis(„ulat‟);
fillpattentype($ba,$ba,$ba,$ba,$ba,$ba,$                 Tulis(„hati);
ba,$ba);
tipistipisver:                                           Lebartek:= textwidth(„keloktipisver‟);
fillpattentype($aa,$aa,$aa,$aa,$aa,$aa,$                 Tinggitek := textheight(„H‟);
aa,$aa);                                                 Settextjustify(centertext,bottomtext);
lekuk:                                                   Setcolor(1);
fillpattentype($c3,$66,$24,$18,$c3,$66,$                 Settextstyle(smallfont,horizdir,4);
24,$18);                                                 Outtextxy(maxx             div         2,maxy-
tipistebalhor:                                           (3*tinggitek),‟fill buatan sendiri„);
fillpattentype($FF,$00,$FF,$FF,$FF,$00,                  X := 1; y := 1;
$FF,$00);                                                Setcolor(3);
tipistipishorr:                                          Settextstyle(smallfont,horizdir,4);
fillpattentype($FF,$00,$FF,$00,$FF,$00,                  Outtextxy(maxx div 2,maxy,‟Gunakan
$FF,$00);                                                anak panahESC=keluar„);
ulat:                                                    X := 1; y := 1;
fillpattentype($FE,$82,$BA,$8A,$FA,$02,                  End;
$FE,$00);                                                Procedure        demofill(pola:fillpatterntype;
hati:                                                    var keluar : char);
fillpattentype($6c,$fe,$fe,$fe,$7c,$38,$10               Begin
,$00);                                                   If keluar = panahup then
                                                         Begin
Var                                                      Dec(y,tinggitek+4);
Maxx,maxy,maxcolor,                                      If y <= 1 then
Lebartext,tinggitext,pilih,x,y : integer;                Begin
Ch,keluar : char;                                        Y := 0;
Key : boolean;                                           Inc(y,tinggitek+4*pilih+1);
                                                         End;
Procedure        blok(xx,yy,panjx,panjy      :           End;
integer);                                                If keluar = panahdn then
Var                                                      Begin
Ty,tx : integer;                                         Inc(y,tinggitek+4);
Begin                                                    If y >= ((tinggitek+4)*pilih+4) then y := 1;
Setcolor(maxcolor);                                      End;
Setwritemode(xorput);                                    Blok(x,y,lebartek,tinggitek+1);
Setlinestyle(solidln,0,normwidth);                       Setfillstyle(pola,2);
For ty := yy to (yy+panjy+1) do                          bar(lebartek+2,0,maxx-10, (maxy div 2 +
Line(xx-1,ty,xx+panjx-1,ty);                             44));
Setwritemode(copyput);                                   ch := readkey;
End;                                                     if ch = null then ch := readkey;
Procedure init;                                          keluar := ch;
Var                                                      blok(x,y,lebartek,tinggitek+1);
Dg,mg : integer;                                         end;
Procedure tulis(kar : string);                           Begin
Begin                                                    Init;
Outtextxy(x,y,kar);                                      Pilih := 0;
Inc(y,textheight(„H‟)+4);                                Keluar := #32;
End;                                                     While keluar <> esc do
Begin                                                    Begin
Dg := detect;                                            Case pilih of
Initgraph(dg,mg,‟ „ );                                   00:demofill(keloktipisver,keluar);
If graphresult <> grok then                              01:demofill(keloktebalver,keluar);
Halt(1);                                                 02:demofill(keloktipishor,keluar);
Maxx := getmaxx;                                         03:demofill(keloktebalhor,keluar);
Maxy := getmaxy;                                         04:demofill(inisialy,keluar);
Maxcolor := getmaxcolor;                                 05:demofill(tipistebalver,keluar);
X := 1; y := 1;                                          06:demofill(tipistipisver,keluar);
Settextstyle(smallfont,horizdir,5);                      07:demofill(lekuk,keluar);
Setcolor(1);                                             08:demofill(tipistebalhor,keluar);
Tulis(„keloktipisver‟);                                  09:demofill(tipistipishor,keluar);

                                            Halaman 31
10:demofill(ulat,keluar);                        Procedure init;
11:demofill(hati,keluar);                        Var
End;                                             Dg,mg : integer;
If keluar = panahdn then                         Begin
If pilih = 11 then pilih = 0                     Dg := detect;
Else                                             Initgraph(dg,mg,‟ „ );
Inc(pilih);                                      If graphresult <> grok then halt(1);
If keluar = panahup then                         Maxx := getmaxx:
If pilih = 0 then pilih := 11                    Maxy := getmaxy;
Else                                             End;
Dec(pilih);                                      Procedure gambar3d;
End;                                             Const
Closegraph;                                      Jmlbalok = 5;
End.                                             Data = array[1..jmlbalok,0..1] of byte =
                                                 ((37,55),(43,25),(32,5),(35,10),(18,55));
Program batang;                                  Var
Uses crt,graph;                                  X1,y1,x2,y2,y3,depth : integer;
Var                                              Item : byte;
Dg,mg : integer;                                 Begin
Procedure buatbar(x,y,panjx : integer;           Rectangle(0,0,maxx,maxy);
fill,warna : word);                              Settextstyle(smallfont,horizdir,5);
Begin                                            Settextjustify(centertext,toptext);
Setfillstyle(fillwarna);                         Outtextxy(maxx div 2,1,‟Demo Bar3D‟);
Bar(x,y,x+panjx,y+panjy);                        X1 := 10;
Procedure init;                                  Depth := 9;
Begin                                            For item := 1 to jmlbalok do begin
Dg := detect;                                    Y1 := maxy + 50;
Initgraph(dg,mg,‟ „ );                           Y2 := y1+data[item,0];
If graphresult <> grok then halt(1);             Y3 := y2-data[item,1];
Setcolor(1);                                     Inc(x1,45);
Rectangle(0,0,getmaxx,getmaxy);                  X2 := x1 + 30;
Settextjustify(centertext,toptext);              Setcolor(3);
Settextstyle(smallfont,horizdir,5);              Setfillstyle(slashfill,3);
Outtextxy(getmaxx div 2,1,‟Pengeluaran           Bar3d(x1,y1,x2,y2,depth,topoff);
Bulan‟);                                         Setcolor(1);
Outtextxy(getmaxx                    div         Setfillstyle(xhatchfill,1);
2,textheight(„H‟)+1,‟Agustus‟);                  Bar3d(x1,y2,x2,y3,depth,topon);
Setcolor(3);                                     End;
Line(109,50,109,150);                            End;
Line(109,150,209,150);                           Begin
Settextjustify(centertext,toptext);              Init;
Settextstyle(smallfont,horizdir,5);              Gambar3d;
Setcolor(1);                                     Repeat until keypressed;
Buatbar(100,160,10,10,slashfill,1);              Closegraph;
Outtextxy(115,160,‟Mejeng‟);                     End.
Setcolor(2);
Buatbar(100,175,10,10,slashfill,1);              TUGAS KE 17
Outtextxy(115,175,‟Nonton‟);                     DARI TABEL BERIKUT
Setcolor(3);                                     BUATLAH GRAFIK HISTOGRAMNYA
Buatbar(200,160,10,10,slashfill,1);              NAMA     TINGGI      BERAT
Outtextxy(215,160,‟Main‟);                       A        176         76
Setcolor(1);                                     B        150         50
Buatbar(200,175,10,10,slashfill,1);              C        165         65
Outtextxy(215,175,‟Shoping‟);                    D        155         55
End;                                             E        178         78
Begin
Init;
Buatbar(112,100,10,49,slashfill,1);
Buatbar(126,80,10,69,slashfill,1);
Buatbar(140,110,10,39,slashfill,1);              PRAKTEK KE 18
Buatbar(154,90,10,59,slashfill,1);               MENGGAMBAR SEGIBANYAK
Repeat until keypressed;
Closegraph;
End.                                             Program segibanyak;
                                                 Uses crt,graph;
Program bar3dimensi;                              const
Use crt,graph;                                   segitiga       :        array[1..4]      of
Var                                              pointtype=((x:100;y:60),(x:50;y:140),(x:15
Maxx,maxy : integer;                             0;y:140),(x:100;y:60));

                                    Halaman 32
segienam:array[1..14]       of     word   =          Var
(249,90,259,80,269,90,269,110,259,120,               Dg,mg,x,y,maxx,maxy,
240,110,249,90)‟                                     Xl,yl,I : integer;
var                                                  Color,maxwarna : word;
dg,mg : integer;                                     Koordinat       :   array[1..maxkoor]       of
begin                                                pointtype;
dg := detect;                                        Jejari : array[1..maxkoor] of word;
initgraph(dg,mg, „ „ );                              Ch : char;
settextstyle(smallfont,horizdir,5);                  Begin
settextjustify(centertext,toptext);                  Dg := detect;
outtextxy(getmaxx div 2, 1, „Demo draw               Initgraph(dg,mg, „ „ );
poly „);                                             If graphresult <> grok then halt(1);
rectangle(30,50,getmaxx-30,150);                     Maxx := getmaxx;
setcolor(1);                                         Maxy := getmaxy;
drawpoly(sizeof(segitiga)               div          Maxwarna := getmaxcolor;
sizeof(pointtype),segitiga);                         For I := 1 to maxkoor do
setcolor(2);                                         Begin
drawpoly(7,segienam);                                Y := random(maxx)+1;
repeat until keypressed;                             X := random(maxy)+1;
end.                                                 End;
                                                     Jejari[i] := random(maxjari);
Program demofillpoly;                                While not keypressed do
Uses crt,graph;                                      Begin
Const                                                I := 0;
Segitiga: array[1..4] of pointtype=                  While (not keypressed) and (I <maxkoor)
(( x : 100; y:60), (x:50; ,y:140), (x:150;           do
,y:140), (x:100;,y:60));                             Begin
                                                     Inc(i);
DuaSegitiga: array[1..5] of pointtype=               Color := random(maxwarna)+1;
(( x : 200; y:60), (x:270; ,y:60), (x:200; ,         Setcolor(color);
y:140), (x:270;, y:140), (x:200;, y:60));            With koordinat[i] do circle(x,y,jejari[i]);
                                                     End;
Var                                                  Setcolor(0);
Dg,mg : integer;                                     I := 0;
Begin                                                While (not keypressed ) and ( I <
Dg := detect;                                        maxkoor) do
Initgraph(dg,mg,‟ „ );                               Begin
If graphresult <> grok then halt(1);                 Inc(i);
Settextstyle(smallfont,horizdir,5);                  With koordinat[i] do circle(x,y,jejari[i]);
Settextjusfify(centertext,toptext);                  End;
Outtextxy(getmaxx           div   2,1,‟Demo          End;
fillpoly‟);                                          Closegraph;
Rectangle(30,50,getmaxx-30,150);                     End.
    Setcolor(1);
Setfillstyle(hatchfill,2);                           Program lingkaranpotong;
Fillpoly(sizeof(segitiga)                div         Uses crt,graph;
sizeof(pointtype),segitiga);                         Const
Setcolor(2);                                         Jari = 50;
Setfillstyle(xhatchfill,1);                          Var
Fillpoly(sizeof(duasegitiga)             div         Dg, mg, dataarc : arccoordstype;
sizeof(pointtype),duasegitiga);                      Begin
Repeat until keypressed;                             Dg := detect;
Closegraph;                                          Initgraph(dg,mg,‟ „ );
End.                                                 If graphresult <> grok then halt(1);
                                                     Setcolor(3);
                                                     Arc(159,99,45,315,jari);
TUGAS KE 18                                          Getarccoords(dataarc);
BUATLAH PROGRAMNYA TABUNG                            With dataarc do
DENGAN ALAS BENTUK SEGI EMPAT                        Begin
DAN SEGI LIMA                                        Line(xstart,ystart,x,y);
                                                     Line(xend,yend,x,y);
PRAKTEK KE 19                                        End;
MENGGAMBAR LINGKARAN                                 Setcolor(2);
                                                     Circle(154,80,3);
Program lingkaran;                                   Repeat until keypressed;
Uses crt,graph;                                      Closegraph;
Const                                                End.
Maxkoor = 100;
Maxjari = 20;                                        Contoh program:

                                        Halaman 33
     Program lonjong;                                    jmldata : real;
     Uses crt,graph;                                     data : array [1..item] of real;
     Var
     Dg,mg : integer;                                    procedure init;
Begin                                                    begin
Dg := detect;                                            dg := detect;
Initgraph(dg,mg, „ „ );                                  initgraph(dg,mg,‟ „);
     If graphresult <> grok then halt(1);                if graphresult <> grok then halt(1);
     I := 4;                                             maxx := getmaxx;
     For k := 1 to 20 do                                 maxy := getmaxy;
     Begin                                               rectangle(0,0,maxx,maxy);
     Setcolor(1);                                        end;
     Ellipse(79,99,0,360,i,70-i);
     Setcolor(2);                                        function inputdata(prompt : string);real;
     Ellipse(239,99,0,360,i,70-i);                       var
     Inc(i,4);                                           data : real;
     End;                                                masukanbenar : boolean;
     Repeat until keypressed;                            posx,posy : byte;
     Closegraph;                                         begin
     End.                                                repeat
                                                         posx := wherex;
                                                         posy := wherey;
    Program lingdarielip;                                {$I-}
    Uses crt,graph;                                      Masukanbenar:=ioresult and (data >= 0 )
    Var                                                  and (data+jml(data<=24);
    Dg,mg,sisix,sisiy : integer;                         If not masukanbenar then
    Aspx,aspy : word;                                    Begin
    Ch : char;                                           Gotoxy(posx,posy);
    Procedure gambarelip;                                Clreol;
    Begin                                                End;
    Getaspectratio(aspx,aspy);                           Until masukanbenar;
    Sisiy := 30;                                         Inputdata := data;
    Sisix := round((aspy/aspx)*sisiy);                   End;
    Setfillstyle(slashfill,2);                           Procedure masukandata;
    Setcolor(3);                                         Begin
    Fillellipse(getmaxx div 2,getmaxy       div          Writeln(„Kegiatan hari ini‟);
    2,sisix,sisiy);                                      Writeln;
    End;                                                 Jmldata := 0;
    Begin                                                For I := 1 to item do
    Dg := detect;                                        Begin
    Initgraph(dg,mg, „ „);                               Data[i] := inputdata(kegiatan[i]);
    If graphresult <> grok then halt(1);                 Jmldata := jmldata+data[i];
    Gambarelip;                                          End;
    Repeat until keypressed;                             End;
    Ch := readkey;                                       Procedure gambarpie;
    Setgraphmode(cgac0);                                 Begin
    Gambarelip;                                          Sdtawal := 0;
    Repeat until keypressed;                             For I := 1 to item do
    Closegraph;                                          Begin
    End.                                                 Bagian := trunc(360*(data[i]/jmldata));
                                                         If I = item then
                                                         Sdtakhir := 360
                                                         Else
                                                         Sdtakhir := sdtawal+bagian;
    Program demokegiatan;                                If data[i] <> 0 then
    Uses crt,graph;                                      Begin
    Const                                                Setfillstyle(i+1,random(maxcolor)+1);
    Item = 5;                                            Pieslice(maxx       div   2,    maxy      div
    Kegiatan : array[1..item] of string =                2,sdtawal,sdtakhir,100);
    („Belajar             :„,                            Sdtawal := sdtakhir;
    „Nonton TV : „,                                      End;
    „Tidur                : „,                           End;
    „Olah Raga : „,                                      End;
    „Belajar              : „);                          Begin
    Var                                                  Masukandata;
    Dg, mg, maxx, maxy,                                  Init;
    Maxcolor : integer;                                  Gambarpie;
    I, bagian, sdtawal,                                  Repeat until keypressed;
    sdtakhir : word;                                     Closegraph;

                                            Halaman 34
End.                                                   Cetak(x,y,‟San Serif Font, ‟);
                                                       Inc(x,textwidth(„sansserif, ‟)+1);
TUGAS KE 19                                            Settextstyle(gothicfont,horizdir,1);
BUATLAH PROGRAMNYA                                     Cetak(x,y,‟Gothic font, ‟);
1. GAMBAR LINGKARAN BANYAK                             Inc(x,textwidth(„gothic, ‟)+1);
   DARI JARI-JARI KECIL KE BESAR
2. GAMBAR LINGKARAN BANYAK                             Settextstyle(smallfont,horizdir,4);
   DARI JARI-JARI BESAR KE KECIL                       Cetak(x,y,‟small font ‟);
3. GAMBAR LINGKARAN BANYAK                             Repeat until keypressed;
   DARI JARI-JARI KECIL KECIL KE                       Closegraph;
   BANYAK                KEMUDIAN                      End.
   MENGHILANG
                                                       Program demoview;
                                                       Uses crt,graph;
                                                       Var
PRAKTEK KE 20                                          Viewinfo : viewporttype;
MEMBUAT TULISAN                                        Xx1,yy1,xx2,yy2,dg,mg : integer;
                                                       Clipp : boolean;
Program Aturhuruf;                                     Ch : char;
Uses crt,graph;                                        Procedure gambarview(tek : string);
Var                                                    Var
Dg,mg,x,y : integer;                                   Sepx,sepy : integer;
Procedure cetak(x,y : integer; tek: string);           Begin
Var                                                    Setviewport(xx1,yy1,xx2,yy2,clipp);
Panjtek,count,lebarkar : integer;                      Clearviewport;
Huruf : string;                                        Rectangle(0,0,(xx2-xx1),(yy2-yy1));
Begin                                                  Settextjustify(centertext,centertext);
Panjtek := length(tek);                                Sepx := (xx2 - xx1) div 2;
For count := 1 to panjtek do                           Sepy := (yy2 – yy1) div 2;
Begin                                                  Outtextxy(sepx,sepy,tek);
Huruf := copy(tek,count,1);                            Circle(sepx,sepy,60);
Lebarkar := textwidth(huruf);                          Repeat until keypressed;
Outtextxy(x,y,huruf);                                  Ch := readkey;
Inc(x,lebarkar);                                       End;
Delay(20);                                             Begin
End;                                                   Dg := detect;
End;                                                   Initgraph(dg,mg,‟ „ );
Begin                                                  If graphresult <> grok then halt(1);
Dg := detect;                                          Xx1 := 9
Initgraph(dg,mg,‟ „ );                                 Yy1 := 49;
If graphresult <> grok then halt(1);                   Xx2 := 109;
Directvideo := false;                                  Yy2 := 159;
X := 0;                                                Clipp := clipon;
Y := 0;                                                Setcolor(2);
Settextstyle(defaultfont,horizdir,1);                  Gambarview(„View 1‟);
Settextjustify(lefttext,toptext);                      Getviewsettings(viewinfo);
Cetak(x,y,‟1. Menggunakan tek grafik                   Xx1 := 89;
turbo pascal‟);                                        Yy1 := 39;
Inc(y,textheight(„H‟)+2);                              Xx2 := 189;
                                                       Yy2 := 139;
Cetak(x,y,‟1. Menggunakan tek grafik                   Clipp := clipoff;
turbo pascal‟);                                        Setcolor(3);
Inc(y,textheight(„H‟)+2);                              Gambarview(„View 2‟);
                                                       With wiewinfo do
Cetak(x,y,‟sangatlah mudah‟);                          Begin
Inc(y,textheight(„H‟)+2);                              Xx1 := x1
                                                       Yy1 := y1;
Cetak(x,y,‟2. Anda bisa memilih huruf                  Xx2 := x2;
yang‟);                                                Yy2 := y2;
Inc(y,textheight(„H‟)+2);                              Clipp := clip;
                                                       Setcolor(2);
Cetak(x,y,‟disediakan oleh pascal‟);                   Gambarview(„View 1‟);
Inc(y,textheight(„H‟)+2);                              End;
Settextstyle(triplexfont,horizdir,3);                  Closegraph;
Settextjustify(lefttext,bottomtext);                   End.
Inc(y,textheight(„H‟)+6);
Cetak(x,y,‟Contohnya triplek font, ‟);
Inc(x,textwidth(„ triplex, ‟)+1);                PRAKTEK KE 21
Settextstyle(sansseriffont,horizdir,1);          MEMBUAT UNIT

                                          Halaman 35
                                           PROCEDURE MAINWINDOW(HEADER :
UNIT HELP1;                                STRING );
INTERFACE                                  PROCEDURE STATUSLINE(MSG :STRING
USES                                       );
 CRT,DOS,GRAPH;                            PROCEDURE WAITTOGO;
                                           PROCEDURE GETDRIVERANDMODE(VAR
CONST                                      DRIVESTR, MODESTR : STRING );
  { THE FIVE FONT AVAILABLE }              PROCEDURE REPORTSTATUS;
  FONTS :ARRAY[0..4] OF STRING[13] =       IMPLEMENTATION
  ('DEFAULTFONT',        'TRIPLEXFONT',
'SMALLFONT',          'SANSSERIFFONT',
'GOTHICFONT');                             {$F+}
                                           PROCEDURE MYEXITPROC;
  { THE FIVE PREDEFINED LINE STYLES        BEGIN
SUPPORTED }                                 EXITPROC := OLDEXITPROC; { RESTORE
  LINESTYLES : ARRAY[0..4] OF STRING[9]    EXIT PROCEDURE ADDRESS }
=                                           CLOSEGRAPH;           { SHUT DOWN
  ('SOLIDLN', 'DOTTEDLN', 'CENTERLN',      THE GRAPHICS SYSTEM }
'DASHEDLN', 'USERBITLN');                  END; { MYEXITPROC }
                                           {$F-}
  { THE TWELVE PREDEFINED FILL
STYLES SUPPORTED }                         PROCEDURE INITIALIZE;
  FILLSTYLES      :  ARRAY[0..11]   OF     { INITIALIZE GRAPHICS AND REPORT ANY
STRING[14] =                               ERRORS THAT MAY OCCUR }
  ('EMPTYFILL', 'SOLIDFILL', 'LINEFILL',   VAR
'LTSLASHFILL', 'SLASHFILL',                  INGRAPHICSMODE : BOOLEAN; { FLAGS
   'BKSLASHFILL',      'LTBKSLASHFILL',    INITIALIZATION OF GRAPHICS MODE }
'HATCHFILL', 'XHATCHFILL',                   PATHTODRIVER : STRING; { STORES
   'INTERLEAVEFILL',      'WIDEDOTFILL',   THE DOS PATH TO *.BGI & *.CHR }
'CLOSEDOTFILL');                           BEGIN
                                             { WHEN USING CRT AND GRAPHICS,
 {   THE    TWO     TEXT   DIRECTIONS      TURN OFF CRT'S MEMORY-MAPPED
AVAILABLE }                                WRITES }
 TEXTDIRECT : ARRAY[0..1] OF STRING[8]       DIRECTVIDEO := FALSE;
= ('HORIZDIR', 'VERTDIR');                   OLDEXITPROC := EXITPROC;         {
                                           SAVE PREVIOUS EXIT PROC }
  {    THE      HORIZONTAL        TEXT       EXITPROC := @MYEXITPROC;
JUSTIFICATIONS AVAILABLE }                   PATHTODRIVER := '';               {
  HORIZJUST : ARRAY[0..2] OF STRING[10]    INSERT OUR EXIT PROC IN CHAIN }
=      ('LEFTTEXT',       'CENTERTEXT',      REPEAT
'RIGHTTEXT');

  { THE VERTICAL TEXT JUSTIFICATIONS       {$IFDEF USE8514}                    {
AVAILABLE }                                CHECK FOR USE8514 $DEFINE }
  VERTJUST : ARRAY[0..2] OF STRING[10]         GRAPHDRIVER := IBM8514;
=     ('BOTTOMTEXT',     'CENTERTEXT',         GRAPHMODE := IBM8514HI;
'TOPTEXT');                                {$ELSE}
                                               GRAPHDRIVER := DETECT;          {
VAR                                        USE AUTODETECTION }
  GRAPHDRIVER : INTEGER;       { THE       {$ENDIF}
GRAPHICS DEVICE DRIVER }
  GRAPHMODE       : INTEGER;    { THE          INITGRAPH         (GRAPHDRIVER,
GRAPHICS MODE VALUE }                      GRAPHMODE, PATHTODRIVER);
  MAXX, MAXY    : WORD;         { THE          ERRORCODE     :=   GRAPHRESULT;
MAXIMUM RESOLUTION OF THE SCREEN           { PRESERVE ERROR RETURN }
}                                              IF ERRORCODE <> GROK THEN
  ERRORCODE : INTEGER; { REPORTS           { ERROR? }
ANY GRAPHICS ERRORS }                          BEGIN
  MAXCOLOR       : WORD;        { THE           WRITELN('GRAPHICS   ERROR:   ',
MAXIMUM COLOR VALUE AVAILABLE }            GRAPHERRORMSG(ERRORCODE));
  OLDEXITPROC : POINTER; { SAVES EXIT           IF        ERRORCODE          =
PROCEDURE ADDRESS }                        GRFILENOTFOUND THEN { CAN'T FIND
PROCEDURE INITIALIZE;                      DRIVER FILE }
FUNCTION INT2STR(L : LONGINT) :                 BEGIN
STRING ;                                         WRITELN ('ENTER FULL PATH TO
FUNCTION RANDCOLOR : WORD;                 BGI DRIVER OR TYPE <CTRL-BREAK> TO
PROCEDURE DEFAULTCOLORS;                   QUIT:');
PROCEDURE DRAWBORDER;                            READLN (PATHTODRIVER);
PROCEDURE FULLPORT;                              WRITELN;

                                    Halaman 36
    END                                    DEFAULTCOLORS;                          {
    ELSE                                 RESET THE COLOR }
     HALT(1)                 { SOME        CLEARDEVICE;                            {
OTHER ERROR: TERMINATE }                 CLEAR THE SCREEN }
   END;                                    SETTEXTSTYLE(DEFAULTFONT,
  UNTIL ERRORCODE = GROK;                HORIZDIR, 1); { DEFAULT TEXT FONT }
  RANDOMIZE;                   { INIT      SETTEXTJUSTIFY            (CENTERTEXT,
RANDOM NUMBER GENERATOR }                TOPTEXT);      { LEFT JUSTIFY TEXT }
  MAXCOLOR := GETMAXCOLOR;          {      FULLPORT;                         { FULL
GET     THE     MAXIMUM  ALLOWABLE       SCREEN VIEW PORT }
DRAWING COLOR }                            OUTTEXTXY(MAXX DIV 2, 2, HEADER);
  MAXX       := GETMAXX;       { GET     { DRAW THE HEADER }
SCREEN RESOLUTION VALUES }                 { DRAW MAIN WINDOW }
  MAXY := GETMAXY;                         SETVIEWPORT (0, TEXTHEIGHT('M')+4,
END; { INITIALIZE }                      MAXX-1,       MAXY-(TEXTHEIGHT('M')+4),
                                         CLIPON);
FUNCTION INT2STR (L : LONGINT) :           DRAWBORDER;
STRING;                                    { MOVE THE EDGES IN1 PIXEL ON ALL
{ CONVERTS AN INTEGER TO A STRING        SIDES SO BORDER ISN'T IN THE VIEW
FOR USE WITH OUTTEXT, OUTTEXTXY }        PORT }
VAR                                        SETVIEWPORT(1,       TEXTHEIGHT('M')+5,
  S : STRING;                            MAXX-1,       MAXY-(TEXTHEIGHT('M')+5),
BEGIN                                    CLIPON);
  STR(L, S);                             END; { MAINWINDOW }
  INT2STR := S;                          PROCEDURE        STATUSLINE       (MSG    :
END; { INT2STR }                         STRING);
FUNCTION RANDCOLOR : WORD;               { DISPLAY A STATUS LINE AT THE
{ RETURN A RANDOM NON-ZERO COLOR         BOTTOM OF THE SCREEN }
VALUE THAT SI WITHIN THE LEGAL           BEGIN
  COLOR RANGE FOR THE SELECTED             FULLPORT;
DEVICE DRIVER AND GRAPHICS MODE.           DEFAULTCOLORS;
  MAXCOLOR IS SET TO GET MAXCOLOR          SETTEXTSTYLE             (DEFAULTFONT,
BY INITIALIZE }                          HORIZDIR, 1);
BEGIN                                      SETTEXTJUSTIFY            (CENTERTEXT,
  RANDCOLOR                       :=     TOPTEXT);
RANDOM(MAXCOLOR)+1;                        SETLINESTYLE          (SOLIDLN,        0,
END; { RANDCOLOR }                       NORMWIDTH);
PROCEDURE DEFAULTCOLORS;                   SETFILLSTYLE (EMPTYFILL, 0);
{ SELECT THE MAXIMUM COOR IN THE           BAR     (0, MAXY-(TEXTHEIGHT('M')+4),
PALETTE FOR HE DRAWING COLOR }           MAXX, MAXY);        { ERASE OLD STATUS
BEGIN                                    LINE }
  SETCOLOR(MAXCOLOR);                      RECTANGLE             (0,         MAXY-
END; { DEFAULTCOLORS }                   (TEXTHEIGHT('M')+4), MAXX, MAXY);
PROCEDURE DRAWBORDER;                      OUTTEXTXY (MAXX DIV 2, MAXY-
{ DRAW A BORDER AROUND THE               (TEXTHEIGHT('M')+2), MSG);
CURRENT VIEW PORT }                        { GO BACK THE MAIN WINDOW }
VAR                                        SETVIEWPORT(1,       TEXTHEIGHT('M')+5,
  VIEWPORT : VIEWPORTTYPE;               MAXX-1,       MAXY-(TEXTHEIGHT('M')+5),
BEGIN                                    CLIPON);
  DEFAULTCOLORS;                         END; { STATUSLINE }
  SETLINESTYLE(SOLIDLN,           0,     PROCEDURE WAITTOGO;
NORMWIDTH);                              { WAIT FOR THE USER TO ABORT THE
  GETVIEWSETTINGS (VIEWPORT);            PROGRAM OR CONTINUE }
  WITH VIEWPORT DO                       CONST
   RECTANGLE(0, 0, X2-X1, Y2-Y1);          ESC = #27;
  END; { DRAWBORDER }                    VAR
PROCEDURE FULLPORT;                        CH : CHAR;
{ SET THE VIEW PORT TO THE ENTIRE        BEGIN
SCREEN }                                   STATUSLINE('ESC ABORTS OR PRESS A
BEGIN                                    KEY...');
   SETVIEWPORT(0, 0, MAXX, MAXY,           REPEAT UNTIL KEYPRESSED;
CLIPON);                                   CH := READKEY;
END; { FULLPORT }                          IF CH = #0 THEN CH := READKEY;          {
PROCEDURE MAINWINDOW (HEADER :           TRAP FUNCTION KEYS }
STRING );                                  IF CH = ESC THEN
{ MAKE A DEFAULT WINDOW AND VIEW             HALT(0)                   { TERMINATE
PORT FOR DEMOS }                         PROGRAM }
BEGIN                                      ELSE


                                  Halaman 37
  CLEARDEVICE;                     { CLEAR       END;
SCREEN, GO ON WITH DEMO }                        WRITEOUT('CURRENT POSITION            :
END; { WAITTOGO }                              ('+INT2STR(GETX)+', '+INT2STR(GETY)+')');
                                                 WRITEOUT('PALETTE ENTRIES             :
                                               '+INT2STR(PALETTE.SIZE));
PROCEDURE GETDRIVERANDMODE (VAR                  WRITEOUT('GETMAXCOLOR                 :
DRIVESTR, MODESTR : STRING);                   '+INT2STR(GETMAXCOLOR));
{ RETURN STRINGS DESCRIBING THE                  WRITEOUT('CURRENT COLOR               :
CURRENT        DEVICE      DRIVER       AND    '+INT2STR(GETCOLOR));
GRAPHICS MODE                                    WITH LINEINFO DO
  FOR DISPLAY OF STATUS REPORT }                 BEGIN
BEGIN                                             WRITEOUT('LINE STYLE                 :
  DRIVESTR := GETDRIVERNAME;                   '+LINESTYLES[LINESTYLE]);
  MODESTR            :=    GETMODENAME            WRITEOUT('LINE THICKNESS             :
(GETGRAPHMODE);                                '+INT2STR(THICKNESS));
END; { GETDRIVERANDMODE }                        END;
PROCEDURE REPORTSTATUS;                          WITH FILLINFO DO
{ DISPLAY THE STATUS OF ALL QUERY                BEGIN
FUNCTIONS AFTER INITGRAPH }                       WRITEOUT('CURRENT FILL STYLE :
CONST                                          '+FILLSTYLES[PATTERN]);
  X = 10;                                         WRITEOUT('CURRENT FILL COLOR :
VAR                                            '+INT2STR(COLOR));
  VIEWINFO      : VIEWPORTTYPE;            {     END;
PARAMETERS              FOR         INQUIRY      WITH TEXTINFO DO
PROCEDURES }                                     BEGIN
  LINEINFO : LINESETTINGSTYPE;                    WRITEOUT('CURRENT FONT               :
  FILLINFO : FILLSETTINGSTYPE;                 '+FONTS[FONT]);
  TEXTINFO : TEXTSETTINGSTYPE;                    WRITEOUT('TEXT DIRECTION             :
  PALETTE : PALETTETYPE;                       '+TEXTDIRECT[DIRECTION]);
  DRIVERSTR : STRING;              { DRIVER       WRITEOUT('CHARACTER SIZE             :
AND MODE STRINGS }                             '+INT2STR(CHARSIZE));
  MODESTR : STRING;                               WRITEOUT('HORIZONTAL JUSTIFY         :
  Y       : WORD;                              '+HORIZJUST[HORIZ]);
PROCEDURE WRITEOUT (S : STRING);                  WRITEOUT('VERTICAL JUSTIFY           :
{ WRITE OUT A STRING AND INCREMENT             '+VERTJUST[VERT]);
TO NEXT LINE }                                   END;
BEGIN                                            WAITTOGO;
  OUTTEXTXY(X, Y, S);                          END; { REPORTSTATUS }
  INC(Y, TEXTHEIGHT('M')+2);                   END.
END; { WRITEOUT }
BEGIN { REPORT STATUS }
  GETDRIVERANDMODE(DRIVERSTR,
MODESTR); { GET CURRENT SETTINGS               UNIT GRAFIK;
}                                              INTERFACE
  GETVIEWSETTINGS(VIEWINFO);                   USES
  GETLINESETTINGS(LINEINFO);                   CRT,GRAPH;
  GETFILLSETTINGS(FILLINFO);                   VAR
  GETTEXTSETTINGS(TEXTINFO);                     GRAPHDRIVER : INTEGER; { THE
  GETPALETTE(PALETTE);                         GRAPHICS DEVICE DRIVER }
  Y := 4;                                        GRAPHMODE        : INTEGER; { THE
  MAINWINDOW('STATUS REPORT AFTER              GRAPHICS MODE VALUE }
INITGRAPH');                                     MAXX,MAXY      : WORD;       { THE
  SETTEXTJUSTIFY(LEFTTEXT, TOPTEXT);           MAXIMUM RESOLUTION OF THE SCREEN
  WRITEOUT('GRAPHICS DEVICE                :   }
'+DRIVERSTR);                                    ERRORCODE : INTEGER; { REPORTS
  WRITEOUT('GRAPHICS MODE                  :   ANY GRAPHICS ERRORS }
'+MODESTR);                                      MAXCOLOR        : WORD;      { THE
  WRITEOUT('SCREEN RESOLUTION : (0,            MAXIMUM COLOR VALUE AVAILABLE }
0,                 '+INT2STR(GETMAXX)+',         OLDEXITPROC : POINTER; { SAVES EXIT
'+INT2STR(GETMAXY)+')');                       PROCEDURE ADDRESS }
  WITH VIEWINFO DO                             PROCEDURE BUKA;
  BEGIN                                        PROCEDURE BIDANG_GAMBAR (VAR
   WRITEOUT('CURRENT VIEW PORT :               X_MIN,Y_MIN,X_MAX,Y_MAX:REAL);
('+INT2STR(X1)+',          '+INT2STR(Y1)+',    PROCEDURE KERANGKA;
'+INT2STR(X2)+', '+INT2STR(Y2)+')');           PROCEDURE              TRANSFORMASI
   IF CLIPON THEN                              (X_MIN,Y_MIN,X_MAX,Y_MAX,
     WRITEOUT('CLIPPING        : ON')               X_GAMBAR,Y_GAMBAR:REAL;
   ELSE                                             VAR X_LAYAR,Y_LAYAR:REAL);
     WRITEOUT('CLIPPING        : OFF');

                                        Halaman 38
PROCEDURE             SUMBU_KOORDINAT         MAXCOLOR := GETMAXCOLOR; { GET
(X_MIN,Y_MIN,X_MAX,Y_MAX:REAL);             THE MAXIMUM ALLOWABLE DRAWING
PROCEDURE                          SKALA    COLOR }
(X_MIN,Y_MIN,X_MAX,Y_MAX:REAL);               MAXX := GETMAXX;          { GET SCREEN
PROCEDURE TULIS_PESAN;                      RESOLUTION VALUES }
PROCEDURE HAPUS_PESAN;                        MAXY := GETMAXY;
PROCEDURE TUTUP;                            END; { INITIALIZE }
IMPLEMENTATION                              PROCEDURE BIDANG_GAMBAR (VAR
{$F+}                                       X_MIN,Y_MIN,X_MAX,Y_MAX:REAL);
PROCEDURE MYEXITPROC;                       BEGIN
BEGIN                                       WRITELN; WRITELN;
    EXITPROC     :=    OLDEXITPROC;     {   WRITELN ('BIDANG GAMBAR:');
RESTORE EXIT PROCEDURE ADDRESS }            WRITE ('TITIK X MINIMUM : ');READLN
    CLOSEGRAPH;            { SHUT DOWN      (X_MIN);
THE GRAPHICSSYSTEM }                        WRITE ('TITIK Y MINIMUM : ');READLN
END; { MYEXITPROC }                         (Y_MIN);
{$F-}                                       WRITE ('TITIK X MAXSIMUM : ');READLN
PROCEDURE BUKA;                             (X_MAX);
{ INITIALIZE GRAPHICS AND REPORT ANY        WRITE ('TITIK Y MAXSIMUM : ');READLN
ERRORS THAT MY OCCUR }                      (Y_MAX);
XVAR                                        END;
   INGRAPHICSMODE : BOOLEAN; { FLAGS        PROCEDURE KERANGKA;
INITIALIZATION OF GRAPHICS MODE }           BEGIN
   PATHTODRIVER : STRING; { STORES          RECTANGLE         (0,0,3*GETMAXX      DIV
THE DOS PATH TO *.BGI & *.CHR }             4,9*GETMAXY DIV 10);
BEGIN                                       RECTANGLE            (3*GETMAXX       DIV
   { WHEN USING CRT AND GRAPHICS,           4,0,GETMAXX,9*GETMAXY DIV 10);
TURN OFF CRT'S MEMORY-MAPPED                RECTANGLE           (0,9*GETMAXY      DIV
WRITES }                                    10,GETMAXX,GETMAXY);
   DIRECTVIDEO := FALSE;                    SETFILLSTYLE (1,BLUE);
   OLDEXITPROC := EXITPROC;             {   FLOODFILL (1,1,WHITE);
SAVE PREVIOUS EXIT PROC }                   SETFILLSTYLE (1,LIGHTBLUE);
   EXITPROC := @MYEXITPROC;             {   FLOODFILL (GETMAXX-1,1,WHITE);
INSERT OUR EXIT PROC IN CHAIN }             SETFILLSTYLE (1,CYAN);
   PATHTODRIVER := '';                      FLOODFILL (1,GETMAXY-1,WHITE);
   REPEAT                                   SETTEXTSTYLE
{$IFDEF USE8514}                 { CHECK    (SMALLFONT,HORIZDIR,5);
FOR USE8514 $DEFINE }                       SETTEXTJUSTIFY              (CENTERTEXT,
      GRAPHDRIVER := IBM8514;               CENTERTEXT);
      GRAPHMODE := IBM8514HI;               OUTTEXTXY            (7*GETMAXX       DIV
{$ELSE}                                     8,GETMAXY DIV 10,'D A T A:');
      GRAPHDRIVER := DETECT;            {   END;
USE OUTODETECTION }                         PROCEDURE                   TRNSFORMASI
{$ENDIF}                                    (X_MIN,Y_MIN,X_MAX,Y_MAX,
   INITGRAPH             (GRAPHDRIVER,            X_GAMBAR,Y_GAMBAR:REAL;
GRAPHMODE, PATHTODRIVER);                         VAR X_LAYAR,Y_LAYAR:REAL);
   ERRORCODE        :=    GRAPHRESULT;      VAR
{ PRESERVE ERROR RETURN }                   XMIN,XMAX,YMIN,YMAX :INTEGER;
   IF ERRORCODE <> GROK THEN            {   BEGIN
ERROR? }                                    XMIN := GETMAXX DIV 10;
   BEGIN                                    XMAX := 3*GETMAXX DIV 4;
    WRITELN ('GRAPHICS ERROR: ',            YMIN := 0;
GRAPHERRORMSG (ERRORCODE));                 YMAX := 8*GETMAXY DIV 10;
    IF ERRORCODE = GRFILENOTFOUND           X_LAYAR           :=         (XMIN*X_MAX-
THEN { CAN'T FIND DRIVER FILE }             XMAX*X_MIN)/(X_MAX-X_MIN)
    BEGIN                                   +       X_GAMBAR*(XMAX-XMIN)/(X_MAX-
      WRITELN ('ENTER FULL PATH TO BGI      X_MIN);
DRIVER OR TYPE <CTRL-BREAK> TO              Y_LAYAR          :=         (YMAX*Y_MAX-
QUIT:');                                    YMIN*Y_MIN)/(Y_MAX-Y_MIN)
      READLN (PATHTODRIVER);                -Y_GAMBAR*(YMAX-YMIN)/(Y_MAX-
      WRITELN;                              Y_MIN);
    END                                     END;
    ELSE                                    PROCEDURE              SUMBU_KOORDINAT
     HALT(1);                     { SOME    (X_MIN,Y_MIN,X_MAX,Y_MAX:REAL);
OTHER ERROR: TERMINATE }                    VAR
    END;                                    X1,Y1,X2,Y2 :REAL;
   UNTIL ERRORCODE = GROK;                  BEGIN
   RANDOMIZE;             { INIT RANDOM
NUMBER GENERATOR }

                                     Halaman 39
TRANSFORMASI                                OUTTEXTXY      (TRUNC      (X1+DEL_1*(N-
(X_MIN,Y_MIN,X_MAX,Y_MAX,X_MIN,0,X1,        1)),17*GETMAXY DIV 20,DTX);
Y1);                                        IF N <> 1 THEN
TRANSFORMASI                                OUTTEXTXY      (TRUNC      (X1+DEL_1*(N-
(X_MIN,Y_MIN,X_MAX,Y_MAX,X_MAX,0,X2         1)),8*GETMAXY DIV 10,'I');
,Y2);                                       END;
LINE(TRUNC(X1),TRUNC(Y1),TRUNC(X2),T        END;
RUNC(Y2));                                  END;
TRANSFORMASI
(X_MIN,Y_MIN,X_MAX,Y_MAX,0,Y_MIN,X1,        PROCEDURE TULIS_PESAN;
Y1);                                        BEGIN
TRANSFORMASI                                SETCOLOR (CYAN);
(X_MIN,Y_MIN,X_MAX,Y_MAX,0,Y_MAX,X2         SETTEXTJUSTIFY
,Y2);                                       (CENTERTEXT,CENTERTEXT);
LINE(TRUNC(X1),TRUNC(Y1),TRUNC(X2),T        OUTTEXTXY        (GETMAXX        DIV
RUNC(Y2));                                  2,19*GETMAXY DIV 20,'TEKAN <ENTER>');
END;                                        REPEAT UNTIL READKEY = #13;
PROCEDURE                          SKALA    END;
(X_MIN,Y_MIN,X_MAX,Y_MAX:REAL);
VAR                                         PROCEDURE HAPUS_PESAN;
DEL,DEL_1,X1,Y1,X2,Y2 :REAL;                BEGIN
N : INTEGER;                                SETCOLOR (CYAN);
DTX: STRING [5];                            SETTEXTJUSTIFY
BEGIN                                       (CENTERTEXT,CENTERTEXT);
TRANSFORMASI                                OUTTEXTXY        (GETMAXX          DIV
(X_MIN,Y_MIN,X_MAX,Y_MAX,X_MIN,Y_MI         2,19*GETMAXY DIV 20,'TEKAN <ENTER>');
N,X1,Y1);                                   SETCOLOR (WHITE);
TRANSFORMASI                                END;
(X_MIN,Y_MIN,X_MAX,Y_MAX,X_MIN,Y_M          PROCEDURE TUTUP;
AX,X2,Y2);                                  BEGIN
LINE(TRUNC(X1),TRUNC(Y1),TRUNC(X2),T        SETCOLOR (CYAN);
RUNC(Y2));                                  SETTEXTSTYLE
SETTEXTSTYLE                                (SMALLFONT,HORIZDIR,5);
(SMALLFONT,HORIZDIR,5);                     SETTEXTJUSTIFY
SETTEXTJUSTIFY                              (CENTERTEXT,RIGHTTEXT);
(CENTERTEXT,CENTERTEXT);                    OUTTEXTXY        (GETMAXX          DIV
DEL := (Y_MAX-Y_MIN)/5;                     2,19*GETMAXY DIV 20,'TEKAN <ESC>');
DEL_1 := (Y2-Y1)/5;                         REPEAT UNTIL READKEY = #27;
FOR N := 1 TO 6 DO                          CLOSEGRAPH;
BEGIN                                       END;
IF N = 6 THEN                               END.
 OUTTEXTXY       (GETMAXX      DIV    20,
TRUNC(Y1+DEL_1*4.75),'Y')                   PRAKTEK KE 22
ELSE                                        PROGRAM DEMO1;
BEGIN                                       USES
STR (Y_MIN+DEL*(N-1):5:2,DTX);                CRT, DOS, GRAPH,HELP1;
OUTTEXTXY           (GETMAXX         DIV
20,TRUNC(Y1+DEL_1*(N-1)),DTX);              PROCEDURE FILLELLIPSEPLAY;
IF N <> 1 THEN                              CONST
OUTTEXTXY           (GETMAXX         DIV      MAXFILLSTYLES = 12;
10,TRUNC(Y1+DEL_1*(N-1)),'-');              VAR
END;                                          MAXRADIUS : WORD;
END;                                          FILLCOLOR : INTEGER;
TRANSFORMASI                                BEGIN
(X_MIN,Y_MIN,X_MAX,Y_MAX,X_MAX,Y_M             MAINWINDOW            ('FILLELLIPSE
IN,X2,Y2);                                  DEMONSTRASION');
LINE(TRUNC(X1),TRUNC(Y1),TRUNC(X2),T           STATUSLINE ('ESC ABORTS OR PRESS
RUNC(Y2));                                  A KEY');
                                               MAXRADIUS := MAXY DIV 10;
DEL := (X_MAX-X_MIN) / 5;                      SETLINESTYLE(SOLIDLN,             0,
DEL_1 := (X2-X1) / 5;                       NORMWIDTH);
FOR N := 1 TO 6 DO                             REPEAT
BEGIN                                           FILLCOLOR := RANDCOLOR;
IF N = 6 THEN                                   SETCOLOR(FILLCOLOR);
OUTTEXTXY                       (TRUNC
(X1+DEL_1*4.75),17*GETMAXY DIV 20,'X')      SETFILLSTYLE(RANDOM(MAXFILLSTYLES
ELSE                                        ), FILLCOLOR);
BEGIN                                            FILLELLIPSE(RANDOM(MAXX),
STR (X_MIN+DEL* (N-1):5:2,DTX);             RANDOM(MAXY),

                                     Halaman 40
          RANDOM(MAXRADIUS),            MAINWINDOW('SETWRITEMODE
RANDOM(MAXRADIUS));                    DEMONSTRASION');
  UNTIL KEYPRESSED;                     STATUSLINE('ESC ABORTS OR PRESS A
  WAITTOGO;                            KEY');
END;                                    GETVIEWSETTINGS(VIEWINFO);
BEGIN                                   LEFT := 0;
  INITIALIZE;                           TOP := 0;
  FILLELLIPSEPLAY;                      WITH VIEWINFO DO
  CLOSEGRAPH;                           BEGIN
END.                                     RIGHT := X2-X1;
                                         BOTTOM := Y2-Y1;
                                        END;
PROGRAM DEMO2;                          STEP := BOTTOM DIV 50;
USES                                    SETCOLOR(GETMAXCOLOR);
  CRT, DOS, GRAPH,HELP1;                LINE(LEFT, TOP, RIGHT, BOTTOM);
                                        LINE(LEFT, BOTTOM, RIGHT, TOP);
PROCEDURE SECTORPLAY;                   SETWRITEMODE(XORPUT);
CONST                                   REPEAT
 MAXFILLSTYLES = 12;                     LINE(LEFT, TOP, RIGHT, BOTTOM);
VAR                                      LINE(LEFT, BOTTOM, RIGHT, TOP);
 MAXRADIUS : WORD;                       RECTANGLE(LEFT,        TOP,    RIGHT,
 FILLCOLOR : INTEGER;                  BOTTOM);
 ENDANGLE : INTEGER;                     DELAY(DELAYVALUE);
BEGIN                                    LINE(LEFT, TOP, RIGHT, BOTTOM);
 MAINWINDOW('SECTOR                      LINE(LEFT, BOTTOM, RIGHT, TOP);
DEMONSTRASION');                         RECTANGLE(LEFT,        TOP,    RIGHT,
 STATUSLINE('ESC ABORTS OR PRESS A     BOTTOM);
KEY');                                   IF   (LEFT+STEP      <  RIGHT)   AND
 MAXRADIUS := MAXY DIV 10;             (TOP+STEP < BOTTOM) THEN
 SETLINESTYLE(SOLIDLN,           0,       BEGIN
NORMWIDTH);                                 INC (LEFT, STEP);
 REPEAT                                     INC (TOP, STEP);
  FILLCOLOR := RANDCOLOR;                   DEC (RIGHT, STEP);
  SETCOLOR(FILLCOLOR);                      DEC (BOTTOM, STEP);
                                          END
SETFILLSTYLE(RANDOM(MAXFILLSTYLES        ELSE
), FILLCOLOR);                            BEGIN
   ENDANGLE := RANDOM(360);                 COLOR := RANDCOLOR;
   SECTOR(RANDOM(MAXX),                     SETCOLOR(COLOR);
RANDOM(MAXY), RANDOM(ENDANGLE),             LEFT := 0;
ENDANGLE,                                   TOP := 0;
       RANDOM(MAXRADIUS),                   WITH VIEWINFO DO
RANDOM(MAXRADIUS));                         BEGIN
  UNTIL KEYPRESSED;                          RIGHT := X2-X1;
  WAITTOGO;                                  BOTTOM := Y2-Y1;
END;                                        END;
                                            END;
BEGIN                                     UNTIL KEYPRESSED;
 INITIALIZE;                              SETWRITEMODE(COPYPUT);
 SECTORPLAY;                              WAITTOGO;
 CLOSEGRAPH;                             END;
END.                                     BEGIN
                                          INITIALIZE;
                                          WRITEMODEPLAY;
                                          CLOSEGRAPH;
PROGRAM DEMO3;                           END.
USES
 CRT, DOS, GRAPH,HELP1;                PROGRAM BGIDEMO4;
                                       USES
PROCEDURE WRITEMODEPLAY;                CRT, DOS, GRAPH,HELP1;
CONST                                  PROCEDURE DEMO;
 DELAYVALUE = 50;                      VAR
VAR                                     VIEWINFO : VIEWPORTTYPE;
 VIEWINFO     : VIEWPORTTYPE;           CENTERX : INTEGER;
 COLOR      : WORD;                     CENTERY : INTEGER;
 LEFT, TOP : INTEGER;                   RADIUS     : WORD;
 RIGHT, BOTTOM : INTEGER;               XASP, YASP : WORD;
 STEP     : INTEGER;                    I     : INTEGER;
BEGIN                                   RADIUSSTEP : WORD;

                                Halaman 41
BEGIN                                        X := (X2-X1)DIV 2;
 MAINWINDOW('SETASPECTRATIO                  Y := TEXTHEIGHT('H');
DEMONSTRATION');                             FOR SIZE := 1 TO 4 DO;
 GETVIEWSETTINGS(VIEWINFO);                  BEGIN
 WITH VIEWINFO DO                             SETTEXTSTYLE(TRIPLEXFONT,
 BEGIN                                    HORIZDIR, SIZE);
  CENTERX := (X2-X1);                         H := TEXTHEIGHT('M');
  CENTERY := (Y2-Y1);                         W := TEXTWIDTH('M');
  RADIUS := 3*((Y2-Y1) DIV 5);                INC(Y, H);
 END;                                         OUTTEXTXY(X,          Y,    'SIZE
 RADIUSSTEP := (RADIUS DIV 30);           '+INT2STR(SIZE));
 CIRCLE(CENTERX, CENTERY, RADIUS);           END;
 GETASPECTRATIO(XASP, YASP);                 INC(Y, H DIV 2);
 FOR I := 1 TO 30 DO                         SETTEXTJUSTIFY(CENTERTEXT,
 BEGIN                                    TOPTEXT);
  SETASPECTRATIO(XASP,                       SETUSERCHARSIZE(5, 6, 3, 2);
YASP+(I*GETMAXX));                           SETTEXTSTYLE(TRIPLEXFONT,
  CIRCLE(CENTERX,              CENTERY,   HORIZDIR, USERCHARSIZE);
RADIUS);DELAY(2000);                         OUTTEXTXY((X2-X1) DIV 2, Y, '
  DEC(RADIUS, RADIUSSTEP);                USERDEFINED SIZE!');
 END;                                       END;
 INC(RADIUS, RADIUSSTEP*30);                WAITTOGO;
 FOR I := 1TO 30 DO                       END;
 BEGIN                                    BEGIN
  SETASPECTRATIO(XASP+(I*GETMAXX),           INITIALIZE;
YASP);                                       DEMO;
  IF RADIUS > RADIUSSTEP THEN             END.
    DEC(RADIUS, RADIUSSTEP);
  CIRCLE(CENTERX, CENTERY, RADIUS);       PROGRAM DEMO6;
 END;                                     USES
 SETASPECTRATIO(XASP, YASP);               CRT, DOS, GRAPH,HELP1;
 WAITTOGO;
END;                                      PROCEDURE DEMO;
BEGIN                                     CONST
   INITIALIZE;                             CGASIZES : ARRAY[0..4] OF WORD = (1,
   DEMO;                                  3, 7, 3, 3);
   CLOSEGRAPH;                             NORMSIZE : ARRAY[0..4] OF WORD = (1,
END.                                      4, 7, 4, 4);
                                          VAR
PROGRAM DEMO5;                             FONT : WORD;
USES                                       VIEWINFO : VIEWPORTTYPE;
 CRT, DOS, GRAPH,HELP1;                    CH        : CHAR;
                                          BEGIN
PROCEDURE DEMO;                            FOR FONT := 0 TO 4 DO
VAR                                        BEGIN
  SIZE : WORD;                               MAINWINDOW(FONTS[FONT]+'
  W, H, X, Y : WORD;                      CHARACTER SET');
  VIEWINFO : VIEWPORTTYPE;                   GETVIEWSETTINGS(VIEWINFO);
BEGIN                                        WITH VIEWINFO DO
  MAINWINDOW('SETTEXTJUSTIFY          /      BEGIN
SETUSERCHARSIZE DEMO');                       SETTEXTJUSTIFY(LEFTTEXT,
  GETVIEWSETTINGS(VIEWINFO);              TOPTEXT);
  WITH VIEWINFO DO                            MOVETO(2, 3);
  BEGIN                                       IF FONT = DEFAULTFONT THEN
   SETTEXTSTYLE(TRIPLEXFONT,                    BEGIN
VERTDIR, 4);                                     SETTEXTSTYLE(FONT, HORIZDIR,
   Y := (Y2-Y1) - 2;                      1);
   SETTEXTJUSTIFY(CENTERTEXT,                    CH := #0;
BOTTOMTEXT);                                     REPEAT
   OUTTEXTXY(2*TEXTWIDTH('M'),       Y,             OUTTEXT(CH);
'VERTICAL');                                        IF (GETX + TEXTWIDTH('M')) > (X2-
   SETTEXTSTYLE(TRIPLEXFONT,              X1) THEN
HORIZDIR, 4);                                         MOVETO      (2,  GETY         +
   SETTEXTJUSTIFY(LEFTTEXT,               TEXTHEIGHT('M')+3);
TOPTEXT);                                           CH := SUCC(CH);
   OUTTEXTXY(2*TEXTWIDTH('M'),       2,          UNTIL (CH >= #255);
'HORIZONTAL');                                  END
   SETTEXTJUSTIFY(CENTERTEXT,                 ELSE
CENTERTEXT);                                    BEGIN

                                   Halaman 42
      IF MAXY < 200 THEN                       POINTS[I].Y     :=    CENTERY      -
        SETTEXTSTYLE(FONT, HORIZDIR,         ADJASP(ROUND(SIN(RADIANS)            *
CGASIZES[FONT]);                             RADIUS));
      CH := '!';                              END;
      REPEAT                                  CIRCLE(CENTERX, CENTERY, RADIUS);
        OUTTEXT(CH);                          FOR I := 0 TO MAXPOINTS - 1 DO
        IF (GETX + TEXTWIDTH('M')) > (X2-     BEGIN
X1) THEN                                       FOR J := I TO MAXPOINTS - 1 DO
         MOVETO(2,        GETY          +      BEGIN
TEXTHEIGHT('M')+3);                             MOVETO(POINTS[I].X, POINTS[I].Y);
        CH := SUCC(CH);                         LINETO(POINTS[J].X, POINTS[J].Y);
      UNTIL (ORD(CH) = ORD('~')+ 1);           END;
     END;                                     END;
  END;                                        WAITTOGO;
  WAITTOGO;                                  END;
 END;                                        BEGIN
END;                                           INITIALIZE;DEMO;
BEGIN                                        END.
  INITIALIZE;
  DEMO;                                      PROGRAM DEMO8;
END.                                         USES
                                              CRT, DOS, GRAPH,HELP1;
PROGRAM DEMO7;                               PROCEDURE DEMO;
USES                                         CONST
 CRT, DOS, GRAPH,HELP1;                       MAXPOINTS = 12;
PROCEDURE DEMO;                              VAR
CONST                                         POLY       : ARRAY[1..MAXPOINTS] OF
 MAXPOINTS = 15;                             POINTTYPE;
VAR                                           CURRPORT : VIEWPORTTYPE;
 POINTS       : ARRAY[0..MAXPOINTS] OF
POINTTYPE;                                   PROCEDURE DRAWTESSERACT;
 VIEWINFO : VIEWPORTTYPE;                    CONST
 I, J  : INTEGER;                             CHECKERBOARD : FILLPATTERNTYPE =
 CENTERX : INTEGER;                          (0, $10, $28, $44, $28, $10, 0, 0);
 CENTERY : INTEGER;                          VAR
 RADIUS     : WORD;                           X, Y, W, H : INTEGER;
 STEPANGLE : WORD;
 XASP, YASP : WORD;                          BEGIN
 RADIANS : REAL;                              GETVIEWSETTINGS(CURRPORT);
                                              WITH CURRPORT DO
FUNCTION ADJASP(VALUE : INTEGER) :            BEGIN
INTEGER;                                       W := (X2-X1) DIV 9;
BEGIN                                          H := (Y2-Y1) DIV 8;
 ADJASP := (LONGINT(VALUE) * XASP)             X := ((X2-X1) DIV 2) - ROUND(2.5 * W);
DIV YASP;                                      Y := ((Y2-Y1) DIV 2) - (3 * H);
END;                                           POLY[1].X := 0; POLY[1].Y := 0;
                                               POLY[2].X := X2-X1; POLY[2].Y := 0;
BEGIN                                          POLY[3].X := X2-X1; POLY[3].Y := Y2-Y1;
 MAINWINDOW('MOVETO,             LINETO        POLY[4].X := 0; POLY[4].Y := Y2-Y1;
DEMONSTRASION');                               POLY[5].X := 0; POLY[5].Y := 0;
 GETASPECTRATIO(XASP, YASP);                   MOVETO(X, Y);
 GETVIEWSETTINGS (VIEWINFO);                   MOVEREL(0, H);         POLY[6].X := GETX;
 WITH VIEWINFO DO                            POLY[6].Y := GETY;
 BEGIN                                         MOVEREL(W, -H); POLY[7].X := GETX;
  CENTERX := (X2-X1) DIV 2;                  POLY[7].Y := GETY;
  CENTERY := (Y2-Y1) DIV 2;                    MOVEREL(4*W, 0); POLY[8].X := GETX;
  RADIUS := CENTERY;                         POLY[8].Y := GETY;
  WHILE (CENTERY+ADJASP(RADIUS)) <             MOVEREL(0, 5*H); POLY[9].X := GETX;
(Y2-Y1)-20 DO                                POLY[9].Y := GETY;
   INC(RADIUS);                                MOVEREL(-W, H);              POLY[10].X :=
 END;                                        GETX; POLY[10].Y := GETY;
 STEPANGLE := 360 DIV MAXPOINTS;               MOVEREL(-4*W, 0);           POLY[11].X :=
 FOR I := 0 TO MAXPOINTS - 1 DO              GETX; POLY[11].Y := GETY;
 BEGIN                                         MOVEREL(0, -5*H);           POLY[12].X :=
  RADIANS := (STEPANGLE * I) * PI / 180;     GETX; POLY[12].Y := GETY;
  POINTS[I].X    :=     CENTERX          +     SETFILLPATTERN(CHECKERBOARD,
ROUND(COS(RADIANS) * RADIUS);                MAXCOLOR);
                                               FILLPOLY(12, POLY);
                                               MOVEREL(W, -H);

                                      Halaman 43
  LINEREL(0, 5*H);    LINEREL(2*W, 0);         RADIUS := (Y2-Y1) DIV 3;
LINEREL(0, -3*H);                             WHILE ADJASP(RADIUS) < ROUND((Y2-
  LINEREL(W, -H);      LINEREL(0, 5*H);     Y1) / 3.6) DO
MOVEREL(0, -5*H);                               INC(RADIUS);
  LINEREL(-2*W, 0);   LINEREL(0, 3*H);       END;
LINEREL(-W, H);                              SETTEXTSTYLE(TRIPLEXFONT,
  MOVEREL(W, -H);        LINEREL(W, 0);     HORIZDIR, 4);
MOVEREL(0, -2*H);                            SETTEXTJUSTIFY(CENTERTEXT,
  LINEREL(-W, 0);                           TOPTEXT);
  FLOODFILL((X2-X1) DIV 2, (Y2-Y1) DIV 2,    OUTTEXTXY(CENTERX, 0, ' THIS IS A PIE
MAXCOLOR);                                  CHART!');
 END;
END;                                         SETTEXTSTYLE(TRIPLEXFONT,
BEGIN                                       HORIZDIR, 3);
 MAINWINDOW('LINEREL       /  MOVEREL
DEMONTRASION');                              SETFILLSTYLE(SOLIDFILL,
 GETVIEWSETTINGS(CURRPORT);                 RANDCOLOR);
 WITH CURRPORT DO                            PIESLICE(CENTERX+10,       CENTERY-
  SETVIEWPORT(X1-1, Y1-1, X2+1, Y2+1,       ADJASP(10), 0, 90, RADIUS);
CLIPON);                                     GETTEXTCOORDS(45, RADIUS, X, Y);
 DRAWTESSERACT;                              SETTEXTJUSTIFY(LEFTTEXT,
 WAITTOGO;                                  BOTTOMTEXT);
END;
BEGIN                                       OUTTEXTXY(CENTERX+10+X+TEXTWIDT
 INITIALIZE;                                H('H'), CENTERY-ADJASP(10+Y), '25 %');
 DEMO;
END.                                         SETFILLSTYLE(HATCHFILL,
                                            RANDCOLOR);
PROGRAM DEMO9;                               PIESLICE(CENTERX, CENTERY, 225, 360,
USES                                        RADIUS);
 CRT, DOS, GRAPH,HELP1;                      GETTEXTCOORDS(293, RADIUS, X, Y);
PROCEDURE DEMO;                              SETTEXTJUSTIFY(LEFTTEXT, TOPTEXT);
VAR
 VIEWINFO : VIEWPORTTYPE;                   OUTTEXTXY(CENTERX+X+TEXTWIDTH('H'
 CENTERX : INTEGER;                         ), CENTERY-ADJASP(Y), '37.5 %');
 CENTERY : INTEGER;
 RADIUS : WORD;                               SETFILLSTYLE(INTERLEAVEFILL,
 XASP, YASP : WORD;                         RANDCOLOR);
 X, Y   : INTEGER;                            PIESLICE(CENTERX-10, CENTERY,135,
                                            225, RADIUS);
                                              GETTEXTCOORDS(180, RADIUS, X, Y);
FUNCTION ADJASP(VALUE : INTEGER) :            SETTEXTJUSTIFY(RIGHTTEXT,
INTEGER ;                                   CENTERTEXT);
BEGIN                                         OUTTEXTXY(CENTERX-10+X-
 ADJASP := (LONGINT(VALUE) * XASP)          TEXTWIDTH('H'),   CENTERY-ADJASP(Y),
DIV YASP;                                   '25 %');
END;                                          SETFILLSTYLE(WIDEDOTFILL,
                                            RANDCOLOR);
PROCEDURE                                     PIESLICE(CENTERX, CENTERY, 90, 135,
GETTEXTCOORDS(ANGLEINDEGREES,               RADIUS);
RADIUS : WORD; VAR X, Y : INTEGER);           GETTEXTCOORDS(112, RADIUS, X, Y);
VAR                                           SETTEXTJUSTIFY(RIGHTTEXT,
 RADIANS : REAL;                            BOTTOMTEXT);
BEGIN                                         OUTTEXTXY(CENTERX+X-
 RADIANS := ANGLEINDEGREES * PI /           TEXTWIDTH('H'),   CENTERY-ADJASP(Y),
180;                                        '12.5 %');
 X := ROUND(COS(RADIANS) * RADIUS);           WAITTOGO;
 Y := ROUND(SIN(RADIANS) * RADIUS);         END;
END;                                        BEGIN
                                              INITIALIZE;
BEGIN                                         DEMO;
 MAINWINDOW('PIESLICE                   /   END.
GETASPECTRATIO DEMONSTRASION');
 GETASPECTRATIO(XASP, YASP);                PROGRAM DEMO10;
 GETVIEWSETTINGS(VIEWINFO);                 USES
 WITH VIEWINFO DO                            CRT, DOS, GRAPH,HELP1;
 BEGIN                                      PROCEDURE DEMO;
  CENTERX := (X2-X1) DIV 2;                 CONST
  CENTERY := ((Y2-Y1) DIV 2) + 20;           NUMBARS = 7;

                                     Halaman 44
 BARHEIGHT : ARRAY[1..NUMBARS] OF                   END;
BYTE = (1, 3, 2, 5, 4, 2, 1);
 YTICKS = 5;                                    END;
VAR                                             WAITTOGO;
 VIEWINFO : VIEWPORTTYPE;                      END;
 H        : WORD;                              BEGIN
 XSTEP : REAL;                                  INITIALIZE;
 YSTEP : REAL;                                  DEMO;
 I, J : INTEGER;                               END.
 DEPTH : WORD;
 COLOR : WORD;
BEGIN
 MAINWINDOW('BAR3D / RECTANGLE                PROGRAM BGIDEMO11;
DEMONSTRATION');                              USES
 H := 3*TEXTHEIGHT('M');                       CRT, DOS, GRAPH,HELP1;
 GETVIEWSETTINGS(VIEWINFO);
 SETTEXTJUSTIFY(CENTERTEXT,                   PROCEDURE DEMO;
TOPTEXT);                                     CONST
 SETTEXTSTYLE(TRIPLEXFONT,                     NUMBARS = 5;
HORIZDIR, 4);                                  BARHEIGHT : ARRAY[1..NUMBARS] OF
 OUTTEXTXY(MAXX DIV 2, 6, 'THESE ARE          BYTE = (1, 3, 5, 2, 4);
3D BARS !');                                   STYLES          : ARRAY[1..NUMBARS] OF
 SETTEXTSTYLE(DEFAULTFONT,                    BYTE = (1, 3, 10, 5, 9);
HORIZDIR, 1);                                 VAR
 WITH VIEWINFO DO                              VIEWINFO : VIEWPORTTYPE;
    SETVIEWPORT(X1+50, Y1+40, X2-50,           BARNUM : WORD;
Y2-10, CLIPON);                                H         : WORD;
 GETVIEWSETTINGS(VIEWINFO);                    XSTEP : REAL;
 WITH VIEWINFO DO                              YSTEP : REAL;
 BEGIN                                         I, J     : INTEGER;
    LINE(H, H, H, (Y2-Y1)-H);                  COLOR : WORD;
    LINE(H, (Y2-Y1)-H, (X2-X1)-H, (Y2-Y1)-    BEGIN
H);                                            MAINWINDOW('BAR            /   RECTANGLE
    YSTEP := ((Y2-Y1)-(2*H)) / YTICKS;        DEMONSTRASION');
    XSTEP := ((X2-X1)-(2*H)) / NUMBARS;        H := 3*TEXTHEIGHT('M');
    J := (Y2-Y1)-H;                            GETVIEWSETTINGS(VIEWINFO);
    SETTEXTJUSTIFY(CENTERTEXT,                 SETTEXTJUSTIFY(CENTERTEXT,
CENTERTEXT);                                  TOPTEXT);
                                               SETTEXTSTYLE(TRIPLEXFONT,
  FOR I := 0 TO YTICKS DO                     HORIZDIR, 4);
  BEGIN                                        OUTTEXTXY(MAXX DIV 2, 6, 'THESE ARE
   LINE(H DIV 2, J, H, J);                    2D BARS !');
   OUTTEXTXY(0, J, INT2STR(I));                SETTEXTSTYLE(DEFAULTFONT,
   J := ROUND(J-YSTEP);                       HORIZDIR, 1);
  END;                                         WITH VIEWINFO DO
                                                 SETVIEWPORT(X1+50, Y1+30, X2-50,
  DEPTH := TRUNC(0.25 * XSTEP);               Y2-10, CLIPON);
                                                 GETVIEWSETTINGS(VIEWINFO);
    SETTEXTJUSTIFY(CENTERTEXT,                   WITH VIEWINFO DO
TOPTEXT);                                        BEGIN
    J := H;                                        LINE(H, H, H, (Y2-Y1)-H);
    FOR I := 1 TO SUCC(NUMBARS) DO                 LINE(H, (Y2-Y1)-H, (X2-X1)-H, (Y2-Y1)-
    BEGIN                                     H);
     SETCOLOR(MAXCOLOR);                           YSTEP := ((Y2-Y1)-(2*H)) / NUMBARS;
     LINE(J, (Y2-Y1)-H, J, (Y2-Y1-3)-(H DIV        XSTEP := ((X2-X1)-(2*H)) / NUMBARS;
2));                                               J := (Y2-Y1)-H;
     OUTTEXTXY(J, (Y2-Y1)-(H DIV 2),               SETTEXTJUSTIFY(CENTERTEXT,
INT2STR(I-1));                                CENTERTEXT);
     IF I <> SUCC(NUMBARS) THEN                    FOR I := 0 TO NUMBARS DO
     BEGIN                                         BEGIN
        COLOR := RANDCOLOR;                         LINE(H DIV 2, J, H, J);
        SETFILLSTYLE(I, COLOR);                     OUTTEXTXY(0, J, INT2STR(I));
        SETCOLOR(COLOR);                            J := ROUND(J-YSTEP);
        BAR3D(J,         ROUND((Y2-Y1-H)-          END;
(BARHEIGHT[I] * YSTEP)),                           J := H;
              ROUND(J+XSTEP-DEPTH),                SETTEXTJUSTIFY(CENTERTEXT,
ROUND((Y2-Y1)-H-1), DEPTH, TOPON);            TOPTEXT);
        J := ROUND(J+XSTEP);                       FOR I := 1 TO SUCC(NUMBARS) DO
        END;                                       BEGIN

                                       Halaman 45
       SETCOLOR(MAXCOLOR);                        YSTEP := ((Y2-Y1)-(2*H)) / NUMBARS;
       LINE(J, (Y2-Y1)-H, J, (Y2-Y1-3)-(H DIV     XSTEP := ((X2-X1)-(2*H)) / NUMBARS;
2));                                              J := (Y2-Y1)-H;
     OUTTEXTXY(J, (Y2-Y1)-(H DIV 2),              SETTEXTJUSTIFY(CENTERTEXT,
INT2STR(I));                                    CENTERTEXT);
     IF I <> SUCC(NUMBARS) THEN
     BEGIN                                            FOR I := 0 TO NUMBARS DO
      COLOR := RANDCOLOR;                             BEGIN
      SETFILLSTYLE(STYLES[I], COLOR);                  LINE(H DIV 2, J, H, J);
      SETCOLOR(COLOR);                                 OUTTEXTXY(0, J, INT2STR(I));
      BAR(J,          ROUND((Y2-Y1-H)-                 J := ROUND(J-YSTEP);
(BARHEIGHT[I]         *        YSTEP)),               END;
ROUND(J+XSTEP), (Y2-Y1)-H-1);
      RECTANGLE(J, ROUND((Y2-Y1-H)-                  J := H;
(BARHEIGHT[I]         *        YSTEP)),              SETTEXTJUSTIFY(CENTERTEXT,
ROUND(J+XSTEP), (Y2-Y1)-H-1);    END;           TOPTEXT);
     J := ROUND(J+XSTEP);                            FOR I := 1 TO SUCC(NUMBARS) DO
   END;                                              BEGIN
   END;                                                SETCOLOR(MAXCOLOR);
   WAITTOGO;                                           LINE(J, (Y2-Y1)-H, J, (Y2-Y1-3)-(H DIV
  END;                                          2));
  BEGIN                                                OUTTEXTXY(J, (Y2-Y1)-(H DIV 2),
    INITIALIZE;                                 INT2STR(I));
    DEMO;                                              IF I <> SUCC(NUMBARS) THEN
    CLOSEGRAPH;                                        BEGIN
  END.                                                  COLOR := RANDCOLOR;
                                                        SETFILLSTYLE(STYLES[I], COLOR);
                                                        SETCOLOR(COLOR);
PROGRAM BGIDEMO12;                                      BAR(J,            ROUND((Y2-Y1-H)-
USES                                            (BARHEIGHT[I]             *         YSTEP)),
 CRT, DOS, GRAPH,HELP1;                         ROUND(J+XSTEP), (Y2-Y1)-H-1);
                                                        RECTANGLE(J, ROUND((Y2-Y1-H)-
PROCEDURE DEMO;                                 (BARHEIGHT[I]             *         YSTEP)),
CONST                                           ROUND(J+XSTEP), (Y2-Y1)-H-1);           END;
 NUMBARS = 5;                                          J := ROUND(J+XSTEP);
 BARHEIGHT : ARRAY[1..NUMBARS] OF                    END;
BYTE = (1, 3, 5, 2, 4);                              END;
 STYLES          : ARRAY[1..NUMBARS] OF              WAITTOGO;
BYTE = (1, 3, 10, 5, 9);                           END;
VAR                                                BEGIN
 VIEWINFO : VIEWPORTTYPE;                             INITIALIZE;
 BARNUM : WORD;                                       DEMO;
 H        : WORD;                                     CLOSEGRAPH;
 XSTEP : REAL;                                     END.
 YSTEP : REAL;
 I, J    : INTEGER;
 COLOR : WORD;                                  PROGRAM DEMO13;
BEGIN                                           USES
 MAINWINDOW('BAR           /   RECTANGLE         CRT, DOS, GRAPH,HELP1;
DEMONSTRASION');
 H := 3*TEXTHEIGHT('M');                        PROCEDURE DEMO;
 GETVIEWSETTINGS(VIEWINFO);                     VAR
 SETTEXTJUSTIFY(CENTERTEXT,                       MAXRADIUS : WORD;
TOPTEXT);                                       BEGIN
 SETTEXTSTYLE(TRIPLEXFONT,                        MAINWINDOW('CIRCLE
HORIZDIR, 4);                                   DEMONSTRASION');
 OUTTEXTXY(MAXX DIV 2, 6, 'THESE ARE              STATUSLINE('ESC ABORTS OR PRESS
2D BARS !');                                    A KEY');
 SETTEXTSTYLE(DEFAULTFONT,                        MAXRADIUS := MAXY DIV 10;
HORIZDIR, 1);                                     SETLINESTYLE(SOLIDLN,         0,
 WITH VIEWINFO DO                               NORMWIDTH);
   SETVIEWPORT(X1+50, Y1+30, X2-50,               REPEAT
Y2-10, CLIPON);                                    SETCOLOR(RANDCOLOR);
   GETVIEWSETTINGS(VIEWINFO);                      CIRCLE(RANDOM(MAXX),
   WITH VIEWINFO DO                             RANDOM(MAXY), RANDOM(MAXRADIUS));
   BEGIN                                          UNTIL KEYPRESSED;
     LINE(H, H, H, (Y2-Y1)-H);                    WAITTOGO;
     LINE(H, (Y2-Y1)-H, (X2-X1)-H, (Y2-Y1)-     END;
H);                                             BEGIN

                                         Halaman 46
 INITIALIZE;                               LINE(X, Y, XEND, YEND);
 DEMO;                                    END;
 CLOSEGRAPH;                             UNTIL KEYPRESSED;
END.                                     WAITTOGO;
                                        END;
PROGRAM DEMO14;                         BEGIN
USES                                     INITIALIZE;
 CRT, DOS, GRAPH,HELP1;                  DEMO;
PROCEDURE DEMO;                          CLOSEGRAPH;
VAR                                     END.
 MAXWIDTH : INTEGER;
 MAXHEIGHT : INTEGER;
 VIEWINFO : VIEWPORTTYPE;
 COLOR : WORD;                          PROGRAM ANIMASI;
BEGIN                                   USES GRAPH,CRT,DOS,HELP1;
 MAINWINDOW('RANDOM BARS');
 STATUSLINE('ESC ABORTS OR PRESS A      procedure demo;
KEY');                                  { Demonstrate the PutPixel and GetPixel
 GETVIEWSETTINGS(VIEWINFO);             commands }
 WITH VIEWINFO DO                       const
 BEGIN                                   Seed      = 1962; { A seed for the random
  MAXWIDTH := X2-X1;                    number generator }
  MAXHEIGHT := Y2-Y1;                    NumPts = 2000; { The number of pixels
 END;                                   plotted }
 REPEAT                                  Esc = #27;
  COLOR := RANDCOLOR;                   var
  SETCOLOR(COLOR);                       I : word;
SETFILLSTYLE(RANDOM(CLOSEDOTFILL)        X, Y, Color : word;
+1, COLOR);                              XMax, YMax : integer;
  BAR3D(RANDOM(MAXWIDTH),                ViewInfo : ViewPortType;
RANDOM(MAXHEIGHT),                      begin
      RANDOM(MAXWIDTH),                  MainWindow('PutPixel         /      GetPixel
RANDOM(MAXHEIGHT), 0, TOPOFF);          demonstration');
  UNTIL KEYPRESSED;                      StatusLine('Esc aborts or press a key...');
  WAITTOGO;
END;                                     GetViewSettings(ViewInfo);
BEGIN                                    with ViewInfo do
  INITIALIZE;                            begin
  DEMO;                                   XMax := (x2-x1-1);
  CLOSEGRAPH;                             YMax := (y2-y1-1);
END.                                     end;

                                         while not KeyPressed do
PROGRAM BGIDEMO15;                       begin
USES                                      { Plot random pixels }
 CRT, DOS, GRAPH,HELP1;                   RandSeed := Seed;
PROCEDURE DEMO;                           I := 0;
VAR                                        while (not KeyPressed) and (I < NumPts)
 MAXRADIUS : WORD;                      do
 ENDANGLE : WORD;                         begin
 ARCINFO : ARCCOORDSTYPE;                   Inc(I);
BEGIN                                       PutPixel(Random(XMax)+1,
 MAINWINDOW('ARC / GETARCCOORDS         Random(YMax)+1, RandColor);
DEMONSTRASION');                          end;
 STATUSLINE('ESC ABORTS OR PRESS
A KEY');                                  { Erase pixels }
 MAXRADIUS := MAXY DIV 10;                RandSeed := Seed;
 REPEAT                                   I := 0;
  SETCOLOR(RANDCOLOR);                     while (not KeyPressed) and (I < NumPts)
  ENDANGLE := RANDOM(360);              do
  SETLINESTYLE(SOLIDLN,           0,      begin
NORMWIDTH);                                 Inc(I);
  ARC(RANDOM(MAXX), RANDOM(MAXY),           X := Random(XMax)+1;
RANDOM(ENDANGLE),          ENDANGLE,        Y := Random(YMax)+1;
RANDOM(MAXRADIUS));                         Color := GetPixel(X, Y);
  GETARCCOORDS(ARCINFO);                    if Color = RandColor then
  WITH ARCINFO DO                             PutPixel(X, Y, 0);
  BEGIN                                   end;
   LINE(X, Y, XSTART, YSTART);           end;

                                 Halaman 47
 WaitToGo;                                      { DrawSaucer }
end; { PutPixelPlay }                           Ellipse(StartX, StartY, 0, 360, r, (r div 3)+2);
begin                                           Ellipse(StartX, StartY-4, 190, 357, r, r div 3);
  initialize;                                   Line(StartX+7, StartY-6, StartX+10, StartY-
  demo;                                        12);
  closegraph;                                   Circle(StartX+10, StartY-12, 2);
end.                                            Line(StartX-7, StartY-6, StartX-10, StartY-
                                               12);
                                                Circle(StartX-10, StartY-12, 2);
program bgidemo;                                SetFillStyle(SolidFill, MaxColor);
uses                                            FloodFill(StartX+1, StartY+4, GetColor);
 crt, dos, graph,help1;
procedure demo;                                 { ReadSaucerImage }
{ Demonstrate the GetImage and PutImage         ulx := StartX-(r+1);
commands }                                      uly := StartY-14;
const                                           lrx := StartX+(r+1);
 r = 20;                                        lry := StartY+(r div 3)+3;
 StartX = 100;
 StartY = 50;                                    Size := ImageSize(ulx, uly, lrx, lry);
                                                 GetMem(Saucer, Size);
var                                              GetImage(ulx, uly, lrx, lry, Saucer^);
 CurPort : ViewPortType;                         PutImage(ulx, uly, Saucer^, XORput);
procedure MoveSaucer(var X, Y : integer;       { erase image }
Width, Height : integer);
var                                             { Plot some "stars" }
 Step : integer;                                for I := 1 to 1000 do
begin                                             PutPixel(Random(MaxX), Random(MaxY),
 Step := Random(2*r);                          RandColor);
 if Odd(Step) then                              X := MaxX div 2;
   Step := -Step;                               Y := MaxY div 2;
 X := X + Step;                                 PauseTime := 70;
 Step := Random(r);
 if Odd(Step) then                               { Move the saucer around }
   Step := -Step;                                repeat
 Y := Y + Step;                                    PutImage(X,     Y,  Saucer^,     XORput);
 { Make saucer bounce off viewport walls }     { draw image }
 with CurPort do                                   Delay(PauseTime);
 begin                                             PutImage(X,     Y,  Saucer^,     XORput);
   if (x1 + X + Width - 1 > x2) then           { erase image }
     X := x2-x1 - Width + 1                        MoveSaucer(X, Y, lrx - ulx + 1, lry - uly +
   else                                        1); { width/height }
     if (X < 0) then                             until KeyPressed;
       X := 0;                                   FreeMem(Saucer, size);
   if (y1 + Y + Height - 1 > y2) then            WaitToGo;
     Y := y2-y1 - Height + 1                   end; { PutImagePlay }
   else                                        begin
     if (Y < 0) then                              initialize;
       Y := 0;                                    demo;
 end;                                             closegraph;
end; { MoveSaucer }                            end.
var
 Pausetime : word;
 Saucer : pointer;                             program BGIdemo;
 X, Y       : integer;                         uses
 ulx, uly : word;                               crt, dos, graph, help1;
 lrx, lry : word;
 Size       : word;                            procedure demo;
 I        : word;                              { Draw random polygons with random fill
begin                                          styles on the screen }
 ClearDevice;                                  const
 FullPort;                                       MaxPts = 5;
                                               type
 { PaintScreen }                                 PolygonType      =   array[1..MaxPts] of
 ClearDevice;                                  PointType;
 MainWindow('GetImage         /     PutImage   var
Demonstration');                                 Poly : PolygonType;
 StatusLine('Esc aborts or press a key...');     I, Color : word;
 GetViewSettings(CurPort);                     begin
                                                 MainWindow('FillPoly demonstration');

                                        Halaman 48
 StatusLine('Esc aborts or press a key...');      end; { FillStylePlay }
 repeat                                           begin
   Color := RandColor;                              initialize;
   SetFillStyle(Random(11)+1, Color);               demo;
   SetColor(Color);                                 closegraph;
   for I := 1 to MaxPts do                        end.
     with Poly[I] do
    begin
      X := Random(MaxX);                          program BGIdemo;
       Y := Random(MaxY);                         uses
    end;                                            crt, dos, graph,help1;
   FillPoly(MaxPts, Poly);
 until KeyPressed;                                procedure demo;
 WaitToGo;                                        { Display some user defined fill patterns }
end; { PolyPlay }                                 const
begin                                               Patterns : array[0..11] of FillPatternType = (
  initialize;                                       ($AA, $55, $AA, $55, $AA, $55, $AA, $55),
  demo;                                             ($33, $33, $CC, $CC, $33, $33, $CC, $CC),
  closegraph;                                       ($F0, $F0, $F0, $F0, $F, $F, $F, $F),
end.                                                (0, $10, $28, $44, $28, $10, 0, 0),
                                                    (0, $70, $20, $27, $25, $27, $4, $4),
                                                    (0, 0, 0, $18, $18, 0, 0, 0),
program BGIdemo;                                    (0, 0, $3C, $3C, $3C, $3C, 0, 0),
uses                                                (0, $7E, $7E, $7E, $7E, $7E, $7E, 0),
  crt, dos, graph,help1;                            (0, 0, $22, $8, 0, $22, $1C, 0),
procedure demo;                                     ($FF, $7E, $3C, $18, $18, $3C, $7E, $FF),
{ Display all of the predefined fill styles         (0, $10, $10, $7C, $10, $10, 0, 0),
available }                                         (0, $42, $24, $18, $18, $24, $42, 0));
var                                               var
 Style : word;                                      Style : word;
 Width : word;                                      Width : word;
 Height : word;                                     Height : word;
 X, Y : word;                                       X, Y : word;
 I, J : word;                                       I, J : word;
 ViewInfo : ViewPortType;                           ViewInfo : ViewPortType;

procedure DrawBox(X, Y : word);                   procedure DrawBox(X, Y : word);
begin                                             begin
 SetFillStyle(Style, MaxColor);                    SetFillPattern(Patterns[Style], MaxColor);
 with ViewInfo do                                  with ViewInfo do
   Bar(X, Y, X+Width, Y+Height);                    Bar(X, Y, X+Width, Y+Height);
 Rectangle(X, Y, X+Width, Y+Height);               Rectangle(X, Y, X+Width, Y+Height);
 OutTextXY(X+(Width div 2), Y+Height+4,            Inc(Style);
Int2Str(Style));                                  end; { DrawBox }
 Inc(Style);
end; { DrawBox }                                  begin
begin                                              MainWindow('User defined fill styles');
 MainWindow('Pre-defined fill styles');            GetViewSettings(ViewInfo);
 GetViewSettings(ViewInfo);                        with ViewInfo do
 with ViewInfo do                                  begin
 begin                                              Width := 2 * ((x2+1) div 13);
   Width := 2 * ((x2+1) div 13);                    Height := 2 * ((y2-10) div 10);
   Height := 2 * ((y2-10) div 10);                 end;
 end;                                              X := Width div 2;
 X := Width div 2;                                 Y := Height div 2;
  Y := Height div 2;                               Style := 0;
 Style := 0;                                       for J := 1 to 3 do
 for J := 1 to 3 do                                begin
 begin                                              for I := 1 to 4 do
   for I := 1 to 4 do                               begin
   begin                                              DrawBox(X, Y);
     DrawBox(X, Y);                                   Inc(X, (Width div 2) * 3);
     Inc(X, (Width div 2) * 3);                     end;
   end;                                             X := Width div 2;
   X := Width div 2;                                Inc(Y, (Height div 2) * 3);
   Inc(Y, (Height div 2) * 3);                     end;
 end;                                              SetTextJustify(LeftText, TopText);
 SetTextJustify(LeftText, TopText);                WaitToGo;
 WaitToGo;                                        end; { FillPatternPlay }

                                           Halaman 49
begin                                           procedure demo;
  initialize;                                   { Demonstrate the use of the SetPalette
  demo;                                         command }
  closegraph;                                   const
end.                                             XBars = 15;
                                                 YBars = 10;
program BGIdemo;                                var
uses                                             I, J : word;
 crt, dos, graph,help1;                          X, Y : word;
procedure demo;                                  Color : word;
{ Display all of the colors available for the    ViewInfo : ViewPortType;
current driver and mode }                        Width : word;
var                                              Height : word;
 Color : word;                                   OldPal : PaletteType;
 Width : word;                                  begin
 Height : word;                                  GetPalette(OldPal);
 X, Y : word;                                    MainWindow('Palette demonstration');
 I, J : word;                                    StatusLine('Press any key...');
 ViewInfo : ViewPortType;                        GetViewSettings(ViewInfo);
procedure DrawBox(X, Y : word);                  with ViewInfo do
begin                                            begin
 SetFillStyle(SolidFill, Color);                   Width := (x2-x1) div XBars;
 SetColor(Color);                                  Height := (y2-y1) div YBars;
 with ViewInfo do                                end;
   Bar(X, Y, X+Width, Y+Height);                 X := 0; Y := 0;
 Rectangle(X, Y, X+Width, Y+Height);             Color := 0;
 Color := GetColor;                              for J := 1 to YBars do
 if Color = 0 then                               begin
 begin                                             for I := 1 to XBars do
   SetColor(MaxColor);                             begin
   Rectangle(X, Y, X+Width, Y+Height);               SetFillStyle(SolidFill, Color);
 end;                                                Bar(X, Y, X+Width, Y+Height);
 OutTextXY(X+(Width div 2), Y+Height+4,              Inc(X, Width+1);
Int2Str(Color));                                     Inc(Color);
 Color := Succ(Color) mod (MaxColor + 1);            Color := Color mod (MaxColor+1);
end; { DrawBox }                                   end;
begin                                              X := 0;
 MainWindow('Color demonstration');                Inc(Y, Height+1);
 Color := 1;                                     end;
 GetViewSettings(ViewInfo);                      repeat
 with ViewInfo do                                  SetPalette(Random(GetMaxColor + 1),
 begin                                          Random(65));
   Width := 2 * ((x2+1) div 16);                 until KeyPressed;
   Height := 2 * ((y2-10) div 10);               SetAllPalette(OldPal);
 end;                                            WaitToGo;
 X := Width div 2;                              end; { PalettePlay }
  Y := Height div 2;                            begin
 for J := 1 to 3 do                               initialize;
 begin                                            demo;
   for I := 1 to 5 do                             closegraph;
   begin                                        end.
     DrawBox(X, Y);
     Inc(X, (Width div 2) * 3);
   end;
   X := Width div 2;                            program BGIdemo;
   Inc(Y, (Height div 2) * 3);                  uses
 end;                                            crt, dos, help1,graph;
 WaitToGo;
end; { ColorPlay }                              procedure demo;
begin                                           { Demonstrate the use of RestoreCrtMode
  initialize;                                   and SetGraphMode }
  demo;                                         var
  closegraph;                                    ViewInfo : ViewPortType;
end.                                             Ch     : char;
                                                begin
                                                 MainWindow('SetGraphMode                /
program BGIdemo;                                RestoreCrtMode demo');
uses                                             GetViewSettings(ViewInfo);
 crt, dos, help1,graph;                          SetTextJustify(CenterText, CenterText);

                                         Halaman 50
  with ViewInfo do                                    for Style := 0 to 3 do
  begin                                               begin
   OutTextXY((x2-x1) div 2, (y2-y1) div 2,              SetLineStyle(Style, 0, ThickWidth);
'Now you are in graphics mode');                       Line(X, Y+20, X, Y2-40);
   StatusLine('Press any key for text                  OutTextXY(X, Y2-30, Int2Str(Style));
mode...');                                             Inc(X, Step);
   repeat until KeyPressed;                           end;
   Ch := ReadKey;                                   end;
   if ch = #0 then ch := readkey;        { trap     SetTextJustify(LeftText, TopText);
function keys }                                     WaitToGo;
   RestoreCrtmode;                                 end; { LineStylePlay }
   Writeln('Now you are in text mode.');           begin
   Write('Press any key to go back to                initialize;
graphics...');                                       demo;
   repeat until KeyPressed;                          closegraph;
   Ch := ReadKey;                                  end.
   if ch = #0 then ch := readkey;        { trap
function keys }                                    program grafik_cosinus;
   SetGraphMode(GetGraphMode);                     uses graph,grafik,crt;
   MainWindow('SetGraphMode                    /   const
RestoreCrtMode demo');                             delx = 0.01;
   SetTextJustify(CenterText, CenterText);         var
   OutTextXY((x2-x1) div 2, (y2-y1) div 2,         xx,x,y,a,n,xl,yl,xmin,ymin,xmax,ymax : real;
'Back in graphics mode...');                       dtx : string;
  end;                                             begin
  WaitToGo;                                        clrscr;
end; { CrtModePlay }                               writeln('paramater fungsi ?');
begin                                              write('Amplitudo ? ');readln(a);
  initialize;                                      write('Frekuensi ? ');readln(n);
  demo;                                            xmin:=-50;
  closegraph;                                      xmax:=360;
end.                                               ymax := a+5;
                                                   YMIN:=-ymax;
program BGIdemo;                                   buka;
uses                                               kerangka;
 crt, dos, help1,graph;                            sumbu_koordinat(xmin,ymin,xmax,ymax);
procedure demo;                                    skala(xmin,ymin,xmax,ymax);
{ Demonstrate the predefined line styles           settextstyle(smallfont,horizdir,5);
available }                                        settextjustify(lefttext,centertext);
var                                                str(a:5:2,dtx);
 Style : word;                                     outtextxy(3*getmaxx div 4,getmaxy div
 Step : word;                                      4+0*getmaxy div 30,'Amp :'+dtx);
 X, Y : word;                                      str(n:5:2,dtx);
 ViewInfo : ViewPortType;                          outtextxy(3*getmaxx div 4,getmaxy div
                                                   4+1*getmaxy div 30,'Fre :'+dtx);
begin                                              x:=xmin;
 ClearDevice;                                      repeat
 DefaultColors;                                    begin
 MainWindow('Pre-defined line styles');            xx := x/57.3;
 GetViewSettings(ViewInfo);                        y :=a*cos(n*xx);
 with ViewInfo do                                  if (y<=ymax) and (y>=ymin) then
 begin                                             begin
  X := 35;                                         transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);
  Y := 10;                                         putpixel(trUnc(xl),trunc(yl),YELLOW);
  Step := (x2-x1) div 11;                          end;
  SetTextJustify(LeftText, TopText);               x:=(x+delx);
  OutTextXY(X, Y, 'NormWidth');                    end;
  SetTextJustify(CenterText, TopText);             until (x>=xmax);
  for Style := 0 to 3 do                           tutup;
  begin                                            end.
    SetLineStyle(Style, 0, NormWidth);
    Line(X, Y+20, X, Y2-40);
    OutTextXY(X, Y2-30, Int2Str(Style));           program grafik_cosinus;
    Inc(X, Step);                                  uses graph,grafik,crt;
  end;                                             const
  Inc(X, 2*Step);                                  delx = 0.01;
  SetTextJustify(LeftText, TopText);               var
  OutTextXY(X, Y, 'ThickWidth');                   xx,x,y,a,n,xl,yl,xmin,ymin,xmax,ymax : real;
  SetTextJustify(CenterText, TopText);             dtx : string;

                                            Halaman 51
begin                                             if cos(n*xx) <> 0 then
clrscr;                                           y :=a*sin(n*xx)/cos(n*xx);
writeln('paramater fungsi ?');                    if (y <=ymax) and (y>=ymin) then
write('Amplitudo ? ');readln(a);                  begin
write('Frekuensi ? ');readln(n);                  transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);
xmin:=-50;                                        putpixel(trUnc(xl),trunc(yl),YELLOW);
xmax:=360;                                        end;
ymax := a+5;                                      x:=(x+delx);
YMIN:=-ymax;                                      end;
buka;                                             until (x>=xmax);
kerangka;                                         tutup;
sumbu_koordinat(xmin,ymin,xmax,ymax);             end.
skala(xmin,ymin,xmax,ymax);
settextstyle(smallfont,horizdir,5);
settextjustify(lefttext,centertext);              program grafik_cotangen;
str(a:5:2,dtx);                                   uses graph,grafik,crt;
outtextxy(3*getmaxx div 4,getmaxy div             const
4+0*getmaxy div 30,'Amp :'+dtx);                  delx = 0.01;
str(n:5:2,dtx);                                   var
outtextxy(3*getmaxx div 4,getmaxy div             xx,x,y,a,n,xl,yl,xmin,ymin,xmax,ymax : real;
4+1*getmaxy div 30,'Fre :'+dtx);                  dtx : string;
x:=xmin;                                          begin
repeat                                            clrscr;
begin                                             writeln('paramater fungsi ?');
xx := x/57.3;                                     write('Amplitudo ? ');readln(a);
y :=a*cos(n*xx);                                  write('Frekuensi ? ');readln(n);
if (y<=ymax) and (y>=ymin) then                   xmin:=-50;
begin                                             xmax:=360;
transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);      ymax :=10*a;
putpixel(trUnc(xl),trunc(yl),YELLOW);             YMIN:=-ymax;
end;                                              buka;
x:=(x+delx);                                      kerangka;
end;                                              sumbu_koordinat(xmin,ymin,xmax,ymax);
until (x>=xmax);                                  skala(xmin,ymin,xmax,ymax);
tutup;                                            settextstyle(smallfont,horizdir,5);
end.                                              settextjustify(lefttext,centertext);
                                                  str(a:5:2,dtx);
program grafik_tangen;                            outtextxy(3*getmaxx div 4,getmaxy div
uses graph,grafik,crt;                            4+0*getmaxy div 30,'Amp :'+dtx);
const                                             str(n:5:2,dtx);
delx = 0.01;                                      outtextxy(3*getmaxx div 4,getmaxy div
var                                               4+1*getmaxy div 30,'Fre :'+dtx);
xx,x,y,a,n,xl,yl,xmin,ymin,xmax,ymax : real;      x:=xmin;
dtx : string;                                     repeat
begin                                             begin
clrscr;                                           xx := x/57.3;
writeln('paramater fungsi ?');                    if cos(n*xx) <> 0 then
write('Amplitudo ? ');readln(a);                  y :=a*cos(n*xx)/sin(n*xx);
write('Frekuensi ? ');readln(n);                  if (y <=ymax) and (y>=ymin) then
xmin:=-50;                                        begin
xmax:=360;                                        transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);
ymax :=10*a;                                      putpixel(trUnc(xl),trunc(yl),YELLOW);
YMIN:=-ymax;                                      end;
buka;                                             x:=(x+delx);
kerangka;                                         end;
sumbu_koordinat(xmin,ymin,xmax,ymax);             until (x>=xmax);
skala(xmin,ymin,xmax,ymax);                       tutup;
settextstyle(smallfont,horizdir,5);               end.
settextjustify(lefttext,centertext);
str(a:5:2,dtx);
outtextxy(3*getmaxx div 4,getmaxy div
4+0*getmaxy div 30,'Amp :'+dtx);                  Grafik fungsi secant
str(n:5:2,dtx);                                   program grafik_secan;
outtextxy(3*getmaxx div 4,getmaxy div             uses graph,grafik,crt;
4+1*getmaxy div 30,'Fre :'+dtx);                  const
x:=xmin;                                          delx = 0.01;
repeat                                            var
begin                                             xx,x,y,a,n,xl,yl,xmin,ymin,xmax,ymax : real;
xx := x/57.3;                                     dtx : string;

                                           Halaman 52
begin                                             repeat
clrscr;                                           begin
writeln('paramater fungsi ?');                    xx := x/57.3;
write('Amplitudo ? ');readln(a);                  if cos(n*xx) <> 0 then
write('Frekuensi ? ');readln(n);                  y :=a/sin(n*xx);
xmin:=-50;                                        if (y <=ymax) and (y>=ymin) then
xmax:=360;                                        begin
ymax :=10*a;                                      transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);
YMIN:=-ymax;                                      putpixel(trUnc(xl),trunc(yl),YELLOW);
buka;                                             end;
kerangka;                                         x:=(x+delx);
sumbu_koordinat(xmin,ymin,xmax,ymax);             end;
skala(xmin,ymin,xmax,ymax);                       until (x>=xmax);
settextstyle(smallfont,horizdir,5);               tutup;
settextjustify(lefttext,centertext);              end.
str(a:5:2,dtx);
outtextxy(3*getmaxx div 4,getmaxy div
4+0*getmaxy div 30,'Amp :'+dtx);                  {$N+,E+}
str(n:5:2,dtx);                                   Program persamaan_kuadrat;
outtextxy(3*getmaxx div 4,getmaxy div             uses
4+1*getmaxy div 30,'Fre :'+dtx);                  crt,graph,grafik;
x:=xmin;                                          const
repeat                                            delx=0.001;
begin                                             var
xx := x/57.3;                                     a,b,c,d,x,y,x1,x2,xl,yl,px,py,
if cos(n*xx) <> 0 then                            xmin,xmax,ymin,ymax : real;
y :=a/cos(n*xx);                                  dtx : string[5];
if (y <=ymax) and (y>=ymin) then                  begin
begin                                             clrscr;
transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);      Writeln('Parameter Fungsi ( nilai A,B,C ) ');
putpixel(trUnc(xl),trunc(yl),YELLOW);             write('Nilai a ? ');readln(a);
end;                                              write('Nilai b ? ');readln(b);
x:=(x+delx);                                      write('Nilai c ? ');readln(c);
end;                                              d:=b*b-4*a*c;
until (x>=xmax);                                  px:=-b/(2*a);
tutup;                                            py:=-d/(4*a);
end.
                                                  if d > 0 then
                                                  begin
                                                  x1 := (-b+sqrt(d))/(2*a);
program grafik_cosecan;                           x2 := (-b-sqrt(d))/(2*a);
uses graph,grafik,crt;                            if x1 < x2 then
const                                             begin
delx = 0.01;                                      xmin := x1-abs(px);
var                                               xmax := x2 + abs(px);
xx,x,y,a,n,xl,yl,xmin,ymin,xmax,ymax : real;      end
dtx : string;                                     else
begin                                             begin
clrscr;                                           xmin := x1 + abs(px);
writeln('paramater fungsi ?');                    xmax := x2 - abs(px);
write('Amplitudo ? ');readln(a);                  end;
write('Frekuensi ? ');readln(n);                  end
xmin:=-50;                                        else
xmax:=360;                                        begin
ymax :=10*a;                                      xmin := px-5*abs(px);
YMIN:=-ymax;                                      xmax := px+5*abs(px);
buka;                                             end;
kerangka;                                         if a>0 then
sumbu_koordinat(xmin,ymin,xmax,ymax);             begin
skala(xmin,ymin,xmax,ymax);                       if py > 0 then
settextstyle(smallfont,horizdir,5);               begin
settextjustify(lefttext,centertext);              ymin := py - 2*abs(py);
str(a:5:2,dtx);                                   ymax := py + 3*abs(py);
outtextxy(3*getmaxx div 4,getmaxy div             end
4+0*getmaxy div 30,'Amp :'+dtx);                  else
str(n:5:2,dtx);                                   begin
outtextxy(3*getmaxx div 4,getmaxy div             ymin := py - abs(py);
4+1*getmaxy div 30,'Fre :'+dtx);                  ymax := py + 3*abs(py);
x:=xmin;                                          end;

                                           Halaman 53
end                                              hapus_pesan;
else                                             tutup;
begin                                            end.
if py < 0 then
begin
ymax := py +2*abs(py);                           {$N+,E+}
ymin := py-3*abs(py);                            program integral;
end                                              uses
else                                             crt,graph,grafik;
begin                                            const
ymax := py +abs(py);                             delx = 0.001;
ymin := py-3*abs(py);                            var
end;                                             x,y,a,b,c,d,x1,y1,x2,y2,luas,
end;                                             xmin,ymin,xmax,ymax : real;
buka;                                            i,n : integer;
kerangka;                                        dtx : string[5];
sumbu_koordinat(xmin,ymin,xmax,ymax);            begin
skala(xmin,ymin,xmax,ymax);                      clrscr;
settextstyle(smallfont,horizdir,5);              write('Jumlah pita ? ');readln(n);
settextjustify(centertext,centertext);           write('Nilai A ? ');readln(a);
outtextxy(7*getmaxx div 8,getmaxy div 6,'Y =     write('Nilai B ? ');readln(b);
ax2 + bx + c ');                                 write('Nilai C ? ');readln(c);
                                                 xmin := -1;
settextjustify(lefttext,centertext);             ymin := -1;
                                                 xmax := 3;
str(a:5:2,dtx);                                  ymax := 4;
outtextxy(3*getmaxx div 4,getmaxy div
6+3*getmaxy div 25,'a='+dtx);                    buka;
str(b:5:2,dtx);                                  kerangka;
outtextxy(3*getmaxx div 4,getmaxy div            sumbu_koordinat(xmin,ymin,xmax,ymax);
6+4*getmaxy div 25,'b='+dtx);                    skala(xmin,ymin,xmax,ymax);
str(c:5:2,dtx);                                  settextstyle(smallfont,horizdir,5);
outtextxy(3*getmaxx div 4,getmaxy div            settextjustify(centertext,centertext);
6+5*getmaxy div 25,'a='+dtx);                    outtextxy(7*getmaxx div 8,getmaxy div 6, 'Y =
x := xmin;                                       ax2 + bx +c ');
repeat
begin                                            settextjustify(lefttext,centertext);
y := a*x*x+b*x+c;                                str(a:5:2,dtx);
if (y<=ymax) and (y>=ymin) then                  outtextxy(3*getmaxx div 4,getmaxy div
begin                                            6+3*getmaxy div 25, 'a='+dtx);
transformasi(xmin,ymin,xmax,ymax,x,y,xl,yl);
putpixel(trunc(xl),trunc(yl),yellow);DELAY(100   str(b:5:2,dtx);
);                                               outtextxy(3*getmaxx div 4,getmaxy div
end;                                             6+4*getmaxy div 25, 'b='+dtx);
x:= x+delx;
end;                                             str(c:5:2,dtx);
until x >= xmax;                                 outtextxy(3*getmaxx div 4,getmaxy div
tulis_pesan;                                     6+5*getmaxy div 25, 'c='+dtx);
settextjustify(lefttext,centertext);
str(d:5:2,dtx);                                  x := xmin;
outtextxy(3*getmaxx div 4,getmaxy div            repeat
6+7*getmaxy div 25,'d='+dtx);                    begin
repeat until readkey=#13;                        y := a*x*x+b*x+c;
if d>0 then                                      if (y<=ymax) and (y >= ymin) then
begin                                            begin
str((-b+sqrt(d))/(2*a):5:2,dtx);                 transformasi(xmin,ymin,xmax,ymax,x,y,x1,y1)
outtextxy(3*getmaxx div 4,getmaxy div            ;
6+9*getmaxy div 25,'x1='+dtx);                   putpixel(trunc(x1),trunc(y1),yellow);
str((-b-sqrt(d))/(2*a):5:2,dtx);                 end;
outtextxy(3*getmaxx div 4,getmaxy div
6+9*getmaxy div 25,'x2='+dtx);                   x := x+delx;
end                                              end;
else                                             until x >= xmax;
begin
outtextxy(3*getmaxx div 4,getmaxy div            tulis_pesan;
6+8*getmaxy div 25,'Bilangan Imajiner');         hapus_pesan;
outtextxy(3*getmaxx div 4,getmaxy div            settextjustify(lefttext,centertext);
6+9*getmaxy div 25,'----------');
end;                                             str(n:2,dtx);

                                          Halaman 54
outtextxy(3*getmaxx div 4,getmaxy div              xx := x/57.3;
6+7*getmaxy div 25, 'pita='+dtx);                  y1 := a*sin(n*xx);
outtextxy(3*getmaxx div 4,getmaxy div              y2 := a*cos(n*xx);
6+8*getmaxy div 25, 'x1=0');                       y12 :=a*sin(n*xx)+a*cos(n*xx);
outtextxy(3*getmaxx div 4,getmaxy div              if (y1<=ymax) and (y1>=ymin) then
6+9*getmaxy div 25, 'x2=0');                       begin
                                                   transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)
d := 2/n;                                          ;
i := 0;                                            putpixel(trUnc(xl),trunc(yl),2);
x := -d/2;                                         end;
luas := 0;                                         if (y2<=ymax) and (y2>=ymin) then
repeat                                             begin
i := i + 1;                                        transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)
x := x + d;                                        ;
y := a*x*x+b*x+c;                                  putpixel(trUnc(xl),trunc(yl),3);
transformasi(xmin,ymin,xmax,ymax,x-                end;
d/2,y,x1,y1);                                      if (y12<=ymax) and (y12>=ymin) then
transformasi(xmin,ymin,xmax,ymax,x+d/2,0,x         begin
2,y2);                                             transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y
rectangle(trunc(x1),trunc(y1),trunc(x2),trunc(y    l);
2));                                               putpixel(trUnc(xl),trunc(yl),4);
                                                   end;
if i mod 2 = 1 then setfillstyle(3,red)            x:=(x+delx);
else                                               end;
setfillstyle(6,red);                               until (x>=xmax);
floodfill(trunc(x1+1),trunc(y1+1),white);          tutup;
luas := luas+y*d;                                  end.
until x > 2-d;
str(luas:5:2,dtx);
outtextxy(3*getmaxx div 4,getmaxy div              Grafik Sinus+Tangen
6+11*getmaxy div 25, 'Luas='+dtx);                 program grafik_sinus_tangen;
hapus_pesan;                                       uses graph,grafik,crt;
tutup;                                             const
end.                                               delx = 0.01;
                                                   var
                                                   xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax
Grafik Sinus+Cosinus                               : real;
program grafik_sinus_cosinus;                      dtx : string;
uses graph,grafik,crt;                             begin
const                                              clrscr;
delx = 0.01;                                       writeln('paramater fungsi ?');
var                                                write('Amplitudo ? ');readln(a);
xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax       write('Frekuensi ? ');readln(n);
: real;                                            xmin:=-50;
dtx : string;                                      xmax:=360;
begin                                              ymax := a+5;
clrscr;                                            YMIN:=-ymax;
writeln('paramater fungsi ?');                     buka;
write('Amplitudo ? ');readln(a);                   kerangka;
write('Frekuensi ? ');readln(n);                   sumbu_koordinat(xmin,ymin,xmax,ymax);
xmin:=-50;                                         skala(xmin,ymin,xmax,ymax);
xmax:=360;                                         settextstyle(smallfont,horizdir,5);
ymax := a+5;                                       settextjustify(lefttext,centertext);
YMIN:=-ymax;                                       str(a:5:2,dtx);
buka;                                              outtextxy(3*getmaxx div 4,getmaxy div
kerangka;                                          4+0*getmaxy div 30,'Amp :'+dtx);
sumbu_koordinat(xmin,ymin,xmax,ymax);              str(n:5:2,dtx);
skala(xmin,ymin,xmax,ymax);                        outtextxy(3*getmaxx div 4,getmaxy div
settextstyle(smallfont,horizdir,5);                4+1*getmaxy div 30,'Fre :'+dtx);
settextjustify(lefttext,centertext);               x:=xmin;
str(a:5:2,dtx);                                    repeat
outtextxy(3*getmaxx div 4,getmaxy div              begin
4+0*getmaxy div 30,'Amp :'+dtx);                   xx := x/57.3;
str(n:5:2,dtx);                                    y1 := a*sin(n*xx);
outtextxy(3*getmaxx div 4,getmaxy div              y2 := a*sin(n*xx)/cos(n*xx);
4+1*getmaxy div 30,'Fre :'+dtx);                   y12:=y1+y2;
x:=xmin;
repeat                                             if (y1<=ymax) and (y1>=ymin) then
begin                                              begin

                                            Halaman 55
transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)   begin
;                                              transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)
putpixel(trUnc(xl),trunc(yl),2);               ;
end;                                           putpixel(trUnc(xl),trunc(yl),3);
                                               end;
if (y2<=ymax) and (y2>=ymin) then              if (y12<=ymax) and (y12>=ymin) then
begin                                          begin
transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)   transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y
;                                              l);
putpixel(trUnc(xl),trunc(yl),3);               putpixel(trUnc(xl),trunc(yl),4);
end;                                           end;
                                               x:=(x+delx);
if (y12<=ymax) and (y12>=ymin) then            end;
begin                                          until (x>=xmax);
transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y    tutup;
l);                                            end.
putpixel(trUnc(xl),trunc(yl),4);
end;
                                               program grafik_cosinus;
x:=(x+delx);                                   uses graph,grafik,crt;
end;                                           const
until (x>=xmax);                               delx = 0.01;
tutup;                                         var
end.                                           xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax
                                               : real;
                                               dtx : string;
program grafik_sinus_tangen;                   begin
uses graph,grafik,crt;                         clrscr;
const                                          writeln('paramater fungsi ?');
delx = 0.01;                                   write('Amplitudo ? ');readln(a);
var                                            write('Frekuensi ? ');readln(n);
xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax   xmin:=-50;
: real;                                        xmax:=360;
dtx : string;                                  ymax := a+5;
begin                                          YMIN:=-ymax;
clrscr;                                        buka;
writeln('paramater fungsi ?');                 kerangka;
write('Amplitudo ? ');readln(a);               sumbu_koordinat(xmin,ymin,xmax,ymax);
write('Frekuensi ? ');readln(n);               skala(xmin,ymin,xmax,ymax);
xmin:=-50;                                     settextstyle(smallfont,horizdir,5);
xmax:=360;                                     settextjustify(lefttext,centertext);
ymax := a+5;                                   str(a:5:2,dtx);
YMIN:=-ymax;                                   outtextxy(3*getmaxx div 4,getmaxy div
buka;                                          4+0*getmaxy div 30,'Amp :'+dtx);
kerangka;                                      str(n:5:2,dtx);
sumbu_koordinat(xmin,ymin,xmax,ymax);          outtextxy(3*getmaxx div 4,getmaxy div
skala(xmin,ymin,xmax,ymax);                    4+1*getmaxy div 30,'Fre :'+dtx);
settextstyle(smallfont,horizdir,5);            x:=xmin;
settextjustify(lefttext,centertext);           repeat
str(a:5:2,dtx);                                begin
outtextxy(3*getmaxx div 4,getmaxy div          xx := x/57.3;
4+0*getmaxy div 30,'Amp :'+dtx);               y1 := a*cos(n*xx);
str(n:5:2,dtx);                                y2 := a/cos(n*xx);
outtextxy(3*getmaxx div 4,getmaxy div          y12 := y1+y2;
4+1*getmaxy div 30,'Fre :'+dtx);
x:=xmin;                                       if (y1<=ymax) and (y1>=ymin) then
repeat                                         begin
begin                                          transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)
xx := x/57.3;                                  ;
y1 := a*sin(n*xx);                             putpixel(trUnc(xl),trunc(yl),2);
y2 := a*cos(n*xx)/sin(n*xx);                   end;
y12:=y1+y2;
if (y1<=ymax) and (y1>=ymin) then              if (y2<=ymax) and (y2>=ymin) then
begin                                          begin
transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)   transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)
;                                              ;
putpixel(trUnc(xl),trunc(yl),2);               putpixel(trUnc(xl),trunc(yl),3);
end;                                           end;
if (y2<=ymax) and (y2>=ymin) then

                                        Halaman 56
if (y12<=ymax) and (y12>=ymin) then            x:=(x+delx);
begin                                          end;
transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y    until (x>=xmax);
l);                                            tutup;
putpixel(trUnc(xl),trunc(yl),4);               end.
end;

x:=(x+delx);                                   program grafik_cosinus;
end;                                           uses graph,grafik,crt;
until (x>=xmax);                               const
tutup;                                         delx = 0.01;
end.                                           var
                                               xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax
                                               : real;
Grafik Sinus+cosecant                          dtx : string;
program grafik_sinus_tangen;                   begin
uses graph,grafik,crt;                         clrscr;
const                                          writeln('paramater fungsi ?');
delx = 0.01;                                   write('Amplitudo ? ');readln(a);
var                                            write('Frekuensi ? ');readln(n);
xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax   xmin:=-50;
: real;                                        xmax:=360;
dtx : string;                                  ymax := a+5;
begin                                          YMIN:=-ymax;
clrscr;                                        buka;
writeln('paramater fungsi ?');                 kerangka;
write('Amplitudo ? ');readln(a);               sumbu_koordinat(xmin,ymin,xmax,ymax);
write('Frekuensi ? ');readln(n);               skala(xmin,ymin,xmax,ymax);
xmin:=-50;                                     settextstyle(smallfont,horizdir,5);
xmax:=360;                                     settextjustify(lefttext,centertext);
ymax := a+5;                                   str(a:5:2,dtx);
YMIN:=-ymax;                                   outtextxy(3*getmaxx div 4,getmaxy div
buka;                                          4+0*getmaxy div 30,'Amp :'+dtx);
kerangka;                                      str(n:5:2,dtx);
sumbu_koordinat(xmin,ymin,xmax,ymax);          outtextxy(3*getmaxx div 4,getmaxy div
skala(xmin,ymin,xmax,ymax);                    4+1*getmaxy div 30,'Fre :'+dtx);
settextstyle(smallfont,horizdir,5);            x:=xmin;
settextjustify(lefttext,centertext);           repeat
str(a:5:2,dtx);                                begin
outtextxy(3*getmaxx div 4,getmaxy div          xx := x/57.3;
4+0*getmaxy div 30,'Amp :'+dtx);               y1 := a*cos(n*xx);
str(n:5:2,dtx);                                y2 := a*sin(n*xx)/cos(n*xx);
outtextxy(3*getmaxx div 4,getmaxy div          y12 := y1+y2;
4+1*getmaxy div 30,'Fre :'+dtx);               if (y1<=ymax) and (y1>=ymin) then
x:=xmin;                                       begin
repeat                                         transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)
begin                                          ;
xx := x/57.3;                                  putpixel(trUnc(xl),trunc(yl),2);
y1 := a*sin(n*xx);                             end;
y2 := a/sin(n*xx);
y12:=y1+y2;                                    if (y2<=ymax) and (y2>=ymin) then
if (y1<=ymax) and (y1>=ymin) then              begin
begin                                          transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)
transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)   ;
;                                              putpixel(trUnc(xl),trunc(yl),3);
putpixel(trUnc(xl),trunc(yl),2);               end;
end;
if (y2<=ymax) and (y2>=ymin) then              if (y12<=ymax) and (y12>=ymin) then
begin                                          begin
transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)   transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y
;                                              l);
putpixel(trUnc(xl),trunc(yl),3);               putpixel(trUnc(xl),trunc(yl),4);
end;                                           end;
if (y12<=ymax) and (y12>=ymin) then
begin                                          x:=(x+delx);
transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y    end;
l);                                            until (x>=xmax);
putpixel(trUnc(xl),trunc(yl),4);               tutup;
end;                                           end.

                                        Halaman 57
                                               var
                                               xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax
program grafik_cosinus;                        : real;
uses graph,grafik,crt;                         dtx : string;
const                                          begin
delx = 0.01;                                   clrscr;
var                                            writeln('paramater fungsi ?');
xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax   write('Amplitudo ? ');readln(a);
: real;                                        write('Frekuensi ? ');readln(n);
dtx : string;                                  xmin:=-50;
begin                                          xmax:=360;
clrscr;                                        ymax := a+5;
writeln('paramater fungsi ?');                 YMIN:=-ymax;
write('Amplitudo ? ');readln(a);               buka;
write('Frekuensi ? ');readln(n);               kerangka;
xmin:=-50;                                     sumbu_koordinat(xmin,ymin,xmax,ymax);
xmax:=360;                                     skala(xmin,ymin,xmax,ymax);
ymax := a+5;                                   settextstyle(smallfont,horizdir,5);
YMIN:=-ymax;                                   settextjustify(lefttext,centertext);
buka;                                          str(a:5:2,dtx);
kerangka;                                      outtextxy(3*getmaxx div 4,getmaxy div
sumbu_koordinat(xmin,ymin,xmax,ymax);          4+0*getmaxy div 30,'Amp :'+dtx);
skala(xmin,ymin,xmax,ymax);                    str(n:5:2,dtx);
settextstyle(smallfont,horizdir,5);            outtextxy(3*getmaxx div 4,getmaxy div
settextjustify(lefttext,centertext);           4+1*getmaxy div 30,'Fre :'+dtx);
str(a:5:2,dtx);                                x:=xmin;
outtextxy(3*getmaxx div 4,getmaxy div          repeat
4+0*getmaxy div 30,'Amp :'+dtx);               begin
str(n:5:2,dtx);                                xx := x/57.3;
outtextxy(3*getmaxx div 4,getmaxy div          y1 := a*cos(n*xx);
4+1*getmaxy div 30,'Fre :'+dtx);               y2 := a/cos(n*xx);
tulis_pesan;                                   y12 := y1+y2;
hapus_pesan;                                   if (y1<=ymax) and (y1>=ymin) then
x:=xmin;                                       begin
repeat                                         transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)
begin                                          ;
xx := x/57.3;                                  putpixel(trUnc(xl),trunc(yl),2);
y1 := a*cos(n*xx);                             end;
y2 := a*cos(n*xx)/sin(n*xx);                   if (y2<=ymax) and (y2>=ymin) then
y12 := y1+y2;                                  begin
                                               transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)
if (y1<=ymax) and (y1>=ymin) then              ;
begin                                          putpixel(trUnc(xl),trunc(yl),3);
transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)   end;
;                                              if (y12<=ymax) and (y12>=ymin) then
putpixel(trUnc(xl),trunc(yl),2);               begin
end;                                           transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y
                                               l);
if (y2<=ymax) and (y2>=ymin) then              putpixel(trUnc(xl),trunc(yl),4);
begin                                          end;
transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)
;                                              x:=(x+delx);
putpixel(trUnc(xl),trunc(yl),3);               end;
end;                                           until (x>=xmax);
if (y12<=ymax) and (y12>=ymin) then            tutup;
begin                                          end.
transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y
l);
putpixel(trUnc(xl),trunc(yl),4);               Grafik cosinus + cosecant
end;                                           program grafik_cosinus;
x:=(x+delx);                                   uses graph,grafik,crt;
end;                                           const
until (x>=xmax);                               delx = 0.01;
tutup;                                         var
end.                                           xx,x,y1,y2,y12,a,n,xl,yl,xmin,ymin,xmax,ymax
program grafik_cosinus;                        : real;
uses graph,grafik,crt;                         dtx : string;
const                                          begin
delx = 0.01;                                   clrscr;

                                        Halaman 58
writeln('paramater fungsi ?');                  m:=length('Panjang gelombang[4000-8000] ?
write('Amplitudo ? ');readln(a);                ');
write('Frekuensi ? ');readln(n);                repeat
xmin:=-50;                                      gotoxy(m,wherey - 1);clreol;
xmax:=360;                                      readln(lamda);
ymax := a+5;                                    until (lamda>=4000) and (lamda<=8000);
YMIN:=-ymax;                                    writeln('Jarak celah [lebih besar panjang
buka;                                           gelombang]? ');
kerangka;                                       repeat
sumbu_koordinat(xmin,ymin,xmax,ymax);           gotoxy(m, wherey - 1);clreol;
skala(xmin,ymin,xmax,ymax);                     readln(d);
settextstyle(smallfont,horizdir,5);             until (d>lamda);
settextjustify(lefttext,centertext);            writeln('Jumlah celah[lebih besar 2] ? ');
str(a:5:2,dtx);                                 repeat
outtextxy(3*getmaxx div 4,getmaxy div           gotoxy(m, wherey - 1);clreol;
4+0*getmaxy div 30,'Amp :'+dtx);                readln(n);
str(n:5:2,dtx);                                 until (n >= 2);
outtextxy(3*getmaxx div 4,getmaxy div           xmin := 0;
4+1*getmaxy div 30,'Fre :'+dtx);                ymin := 0;
x:=xmin;                                        xmax := 60;
repeat                                          ymax := sqr(n)+5;
begin                                           buka;
xx := x/57.3;                                   kerangka;
y1 := a*cos(n*xx);                              sumbu_koordinat(xmin,ymin,xmax,ymax);
y2 := a/sin(n*xx);                              skala(xmin,ymin,xmax,ymax);
y12 := y1+y2;                                   settextstyle(smallfont,horizdir,5);
                                                settextjustify(lefttext,centertext);
if (y1<=ymax) and (y1>=ymin) then               str(n:5,dtx);
begin                                           outtextxy(3*getmaxx div 4, getmaxy div
transformasi(xmin,ymin,xmax,ymax,x,y1,xl,yl)    4+0*getmaxy div 30,'Jml celah:'+dtx);
;                                               str(d:5,dtx);
putpixel(trUnc(xl),trunc(yl),2);                outtextxy(3*getmaxx div 4, getmaxy div
end;                                            4+1*getmaxy div 30,'Jrk celah:'+dtx);
                                                str(lamda:5,dtx);
if (y2<=ymax) and (y2>=ymin) then               outtextxy(3*getmaxx div 4, getmaxy div
begin                                           4+2*getmaxy div 30,'Pnj.gel:'+dtx);
transformasi(xmin,ymin,xmax,ymax,x,y2,xl,yl)    xx := xmin;
;                                               repeat
putpixel(trUnc(xl),trunc(yl),3);                delta := 2*pi*d*sin(xx/57.3)/lamda;
end;                                            ax:=0;
                                                ay:=0;
if (y12<=ymax) and (y12>=ymin) then             for i:=1 to n do
begin                                           begin
transformasi(xmin,ymin,xmax,ymax,x,y12,xl,y     ax:=ax+cos(i*delta);
l);                                             ay:=ay+sin(i*delta);
putpixel(trUnc(xl),trunc(yl),4);                end;
end;                                            yy:=sqr(ax)+sqr(ay);
                                                transformasi(xmin,ymin,xmax,ymax,xx,yy,x,y)
                                                ;
x:=(x+delx);                                    putpixel(trunc(x),trunc(y),white);
end;                                            xx := xx + delx;
until (x>=xmax);                                until xx >= xmax;
tutup;                                          tutup;
end.                                            end.


Grafik Interferensi ke-1 antara 2 gelombang     program interferensi;
program interferensi;                           uses crt,graph,grafik;
uses crt,graph,grafik;                          const
const                                           delx = 0.02;
delx = 0.02;                                    var
var                                             xmin,ymin,xmax,ymax,
xmin,ymin,xmax,ymax,                            ax,ay,d,gamma,lamda,x,xx,y,yy : real;
ax,ay,d,delta,lamda,x,xx,y,yy : real;           i,m,n : integer;
i,m,n : integer;                                dtx : string[5];
dtx : string[5];                                begin
begin                                           clrscr;
clrscr;                                         writeln('Panjang gelombang[4000-8000] ? ');
writeln('Panjang gelombang[4000-8000] ? ');

                                         Halaman 59
m:=length('Panjang gelombang[4000-8000] ?           dtx : string[5];
');                                                 begin
repeat                                              clrscr;
gotoxy(m,wherey - 1);clreol;                        writeln('Panjang gelombang[4000-8000] ? ');
readln(lamda);                                      m:=length('Panjang gelombang[4000-8000] ?
until (lamda>=4000) and (lamda<=8000);              ');
                                                    repeat
writeln('Jarak celah [lebih besar panjang           gotoxy(m,wherey - 1);clreol;
gelombang]? ');                                     readln(lamda);
repeat                                              until (lamda>=4000) and (lamda<=8000);
gotoxy(m,wherey - 1);clreol;                        writeln('Lebar celah [lebih besar panjang
readln(d);                                          gelombang]? ');
until (d>lamda);                                    repeat
                                                    gotoxy(m,wherey - 1);clreol;
writeln('Jumlah celah[lebih besar 2] ? ');          readln(d);
repeat                                              until (d>lamda);
gotoxy(m,wherey - 1);clreol;                        xmin := -60;
readln(n);                                          ymin := 0;
until (n >= 2);                                     xmax := 60;
                                                    ymax := 1.3;
xmin := 0;                                          buka;
ymin := 0;                                          kerangka;
xmax := 60;                                         sumbu_koordinat(xmin,ymin,xmax,ymax);
ymax := sqr(n)+5;                                   skala(xmin,ymin,xmax,ymax);
                                                    settextstyle(smallfont,horizdir,5);
buka;                                               settextjustify(lefttext,centertext);
kerangka;                                           str(d:5,dtx);
sumbu_koordinat(xmin,ymin,xmax,ymax);               outtextxy(3*getmaxx div 4, getmaxy div
skala(xmin,ymin,xmax,ymax);                         4+1*getmaxy div 30,'Lbr.celah:'+dtx);
settextstyle(smallfont,horizdir,5);                 str(lamda:5,dtx);
settextjustify(lefttext,centertext);                outtextxy(3*getmaxx div 4, getmaxy div
                                                    4+2*getmaxy div 30,'Pnj.gel:'+dtx);
str(n:5,dtx);                                       xx := xmin;
outtextxy(3*getmaxx div 4, getmaxy div              repeat
4+0*getmaxy div 30,'Jml celah:'+dtx);               beta := pi*d*sin(xx/57.3)/lamda;
                                                    if beta <> 0 then
str(d:5,dtx);                                       begin
outtextxy(3*getmaxx div 4, getmaxy div              yy:=sqr(sin(beta)/beta);
4+1*getmaxy div 30,'Jrk celah:'+dtx);               transformasi(xmin,ymin,xmax,ymax,xx,yy,x,y)
                                                    ;
str(lamda:5,dtx);                                   putpixel(trunc(x),trunc(y),white);
outtextxy(3*getmaxx div 4, getmaxy div              end;
4+2*getmaxy div 30,'Pnj.gel:'+dtx);                 xx := xx + delx;
                                                    until xx >= xmax;
xx := xmin;                                         tutup;
repeat                                              end.
gamma := 2*pi*d*sin(xx/57.3)/lamda;
if gamma <> 0 then
begin                                               program difraksi_interferensi;
yy:=sqr(sin(n*gamma)/sin(gamma));                   uses crt,graph,grafik;
transformasi(xmin,ymin,xmax,ymax,xx,yy,x,y)         const
;                                                   delx = 0.02;
putpixel(trunc(x),trunc(y),white);                  var
end;                                                xmin,ymin,xmax,ymax,
xx := xx + delx;                                    ax,ay,b,d,beta,gamma,lamda,x,xx,y,yy : real;
until xx >= xmax;                                   i,m,n : integer;
tutup;                                              dtx : string[5];
end.                                                begin
                                                    clrscr;
                                                    writeln('Panjang gelombang[4000-8000] ? ');
Grafik Difraksi gelombang                           m:=length('Panjang gelombang[4000-8000] ?
program difraksi;                                   ');
uses crt,graph,grafik;                              repeat
const                                               gotoxy(m,wherey - 1);clreol;
delx = 0.02;                                        readln(lamda);
var                                                 until (lamda>=4000) and (lamda<=8000);
xmin,ymin,xmax,ymax,
ax,ay,d,beta,lamda,x,xx,y,yy : real;                writeln('Jumlah celah[lebih besar 2] ? ');
i,m : integer;                                      repeat

                                             Halaman 60
gotoxy(m,wherey - 1);clreol;                       uses crt,graph,grafik;
readln(n);                                         const
until (n >= 2);                                    delx = 0.001;
writeln('Lebar celah [lebih besar panjang          xmin = 0;
gelombang]? ');                                    ymin = 0;
repeat                                             xmax = 10;
gotoxy(m,wherey - 1);clreol;                       ymax = 10;
readln(b);
until (b>lamda);                                   var
writeln('Jarak celah[lebih besar lebar celah] ?    x,y,x1,y1 : real;
');                                                v,vs,i,j : integer;
repeat                                             dtx : string[5];
gotoxy(m,wherey - 1);clreol;                       begin
readln(d);                                         clrscr;
until (d >= b);                                    writeln('Kecepatan [5 - 10] ? ');
xmin := -80;                                       writeln;
ymin := 0;                                         write('Kecepatan sumber ? ');readln(vs);
xmax := 80;                                        write('Kecepatan mutlak ? ');readln(v);
ymax := sqr(n)+5;
                                                   buka;
buka;                                              kerangka;
kerangka;                                          sumbu_koordinat(xmin,ymin,xmax,ymax);
sumbu_koordinat(xmin,ymin,xmax,ymax);              skala(xmin,ymin,xmax,ymax);
skala(xmin,ymin,xmax,ymax);                        settextstyle(smallfont,horizdir,5);
settextstyle(smallfont,horizdir,5);                settextjustify(lefttext,centertext);
settextjustify(lefttext,centertext);               str(vs:5,dtx);
                                                   outtextxy(3*getmaxx div 4,getmaxy div
str(n:5,dtx);                                      4,'Kec.Sum:'+dtx);
outtextxy(3*getmaxx div 4, getmaxy div             str(v:5,dtx);
4+0*getmaxy div 30,'Jml.cel:'+dtx);                outtextxy(3*getmaxx div 4,getmaxy div
                                                   4+getmaxy div 30,'Kec.mut:'+dtx);
str(d:5:2,dtx);
outtextxy(3*getmaxx div 4, getmaxy div             x := xmax/2;
4+1*getmaxy div 30,'Jrk.cel:'+dtx);                for i := 1 to 15 do
                                                   begin
str(lamda:5:2,dtx);                                for j := i downto 0 do
outtextxy(3*getmaxx div 4, getmaxy div             begin
4+2*getmaxy div 30,'Pnj.gel:'+dtx);                transformasi(xmin,ymin,xmax,ymax,x,ymax/2,
                                                   x1,y1);delay(2000);
str(b:5:2,dtx);                                    setcolor(black);circle(trunc(x1)+(j-
outtextxy(3*getmaxx div 4, getmaxy div             i)*vs,trunc(y1),(i-j)*v);
4+3*getmaxy div 30,'Leb.cel:'+dtx);                setcolor(white);circle(trunc(x1)+j*vs,trunc(y1),
                                                   (i-j)*v);

xx := xmin;                                        end;
repeat                                             end;
beta := pi*b*sin(xx/57.3)/lamda;                   tutup;
if beta <> 0 then yy := sqr(n)                     end.
else yy:=sqr(n*sin(beta)/beta);
transformasi(xmin,ymin,xmax,ymax,xx,yy,x,y)
;                                                  Grafik Lisajous
putpixel(trunc(x),trunc(y),yellow);                program lisajous;
                                                   uses crt,graph,grafik;
gamma := pi*d*sin(xx/57.3)/lamda;                  const
if gamma = 0 then yy := yy                         delx = 0.01;
else                                               var
yy := yy*sqr(sin(n*gamma)/(n*sin(gamma)));         xmin,ymin,xmax,ymax,
transformasi(xmin,ymin,xmax,ymax,xx,yy,x,y)        t,x1,y1,x,y,a,b,omegax,omegay,pix,piy : real;
;                                                  dtx : string[5];
putpixel(trunc(x),trunc(y),white);                 begin
                                                   clrscr;
xx := xx + delx;
until xx >= xmax;                                  writeln('Parameter gelombang 1');
tutup;                                             write('Amplitudo ? ');readln(a);
end.                                               write('Frekuensi ? ');readln(omegax);
                                                   write('Sudut Fasa? ');readln(pix);

Grafik Doppler                                     writeln('Parameter gelombang 2');
program doppler;                                   write('Amplitudo ? ');readln(b);

                                            Halaman 61
write('Frekuensi ? ');readln(omegay);
write('Sudut Fasa? ');readln(piy);

xmin := -(a+b+10);
ymin := xmin;
xmax := -xmin;
ymax := xmax;

buka;
kerangka;
sumbu_koordinat(xmin,ymin,xmax,ymax);
skala(xmin,ymin,xmax,ymax);

settextstyle(smallfont,horizdir,5);
settextjustify(lefttext,centertext);

str(a:5,dtx);
outtextxy(3*getmaxx div 4, getmaxy div
4+0*getmaxy div 30,'Amp 1:'+dtx);

str(omegax:5,dtx);
outtextxy(3*getmaxx div 4, getmaxy div
4+1*getmaxy div 30,'Fre 1:'+dtx);

str(pix:5,dtx);
outtextxy(3*getmaxx div 4, getmaxy div
4+2*getmaxy div 30,'Fas l:'+dtx);

str(b:5,dtx);
outtextxy(3*getmaxx div 4, getmaxy div
4+3*getmaxy div 30,'Amp 2:'+dtx);

str(omegay:5,dtx);
outtextxy(3*getmaxx div 4, getmaxy div
4+4*getmaxy div 30,'Fre 2:'+dtx);

str(piy:5,dtx);
outtextxy(3*getmaxx div 4, getmaxy div
4+5*getmaxy div 30,'Fas 2:'+dtx);

settextjustify(centertext,centertext);
outtextxy(getmaxx div 2, 19*getmaxy div
20,'Tekan Enter');

pix := pix/57.3;
piy := piy/57.3;

t := 0;
repeat
begin
x := a*sin(omegax*t+pix);
y := b*sin(omegay*t+piy);

transformasi(xmin,ymin,xmax,ymax,x,y,x1,y1)
;
putpixel(trunc(x1),trunc(y1),white);

t := t+delx;
end;
until keypressed;
setcolor(black);
outtextxy(getmaxx div 2, 19*getmaxy div
20,'Tekan Enter');
setcolor(white);
tutup;
end.




                                          Halaman 62

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3892
posted:2/8/2010
language:Indonesian
pages:62