Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

tugas 1

1,285 views

Published on

tugas ui

Published in: Education, Travel, Technology
  • Be the first to comment

tugas 1

  1. 1. DEKLARASI LABEL PROGRAM cetak; • LABEL satu,akhir; • BEGIN • WRITELN('STMIK'); • GOTO SATU; • WRITELN('BINA'); • satu: • WRITELN('GUNADARMA'); • GOTO akhir; • WRITELN('SARANA'); • akhir: • END. • output
  2. 2. Deklarasi konstanta PROGRAM CETAK_2(OUTPUT); • CONST a = 50; (* selalu menggunakan tanda = *) • b = 'INDONESIA Merdeka'; • BEGIN • WRITELN(a,' TAHUN '); • WRITELN(b); • END. • output
  3. 3. Deklarasi tipe PROGRAM SATU; • TYPE bulat = INTEGER; { selalu menggunakan = } • hasil,pecahan = REAL; • ket = STRING[20]; • BEGIN • pecahan := 2.52; • bulat := 2; • hasil := pecahan + bulat; • ket := 'hasil penjumlahan = '; • WRITE(ket,hasil:4:2); • END. • Output
  4. 4. Deklarasi variabel/perubah VAR satu : INTEGER; • dua : INTEGER; • a : REAL; • b : REAL; { selalu menggunakan : } • BEGIN • satu := 5; • dua := 4; • a := 2.3; • b := 5+4*2.3; { hasil real } • WRITE('hasil = ',b:4:1); • END • Output
  5. 5. TYPE DATA INTEGER VAR a,b,jumlah1,jumlah2 : INTEGER; • BEGIN • jumlah1:=10; • jumlah2:=3; • a:=jumlah1 DIV jumlah2; • b:=jumlah1 MOD jumlah2; • WRITELN('HASIL A = ',a); • WRITELN('HASIL B =',b); • END. • OUTPUT
  6. 6. Tipe data real VAR nilai1,nilai2,hasil : REAL; • BEGIN • nilai1 := 2.52; • nilai2 := 3.2; • hasil := nilai1 + nilai2; • WRITE('HASIL PENJUMLAHAN = ',hasil:4:2); • END. • OUTPUT
  7. 7. Tipe data karakter VAR nilai : CHAR; • BEGIN • nilai :='A'; • WRITELN('NILAI TERBAIK = ',nilai); • END. • OUTPUT Tipe data string VAR kata1 : STRING[5]; • kata2 : STING[9]; • kata : CHAR; • BEGIN • kata1 :='STMIK'; • kata2 :='GUNADARMA'; • kata :=' '; { karakter berupa spasi } • WRITELN(kata1,kata,kata2); • END. •
  8. 8. OUTPUT Tipe data Boolean VAR • benar : BOOLEAN; • BEGIN • benar := TRUE; • WRITELN('benar = ',benar); • END. • OUTPUT
  9. 9. Program Deret; • VAR • I,J,K = INTEGER; • BEGIN • K := 2; • FOR I := 3 DOWNTO 0 DO • BEGIN • J := I + 2 ; • WRITELN (I,J); • END; • READLN; • END. OUTPUT PROGRAM LUAS SEGIEMPAT; • VAR • P,L,LUAS : INTEGER;
  10. 10. • BEGIN • WRITE(‘Masukkan panjang = ‘);readln(P); • WRITE(‘Masukkan lebar= ‘);readln(L); • LUAS := P * L; • WRITE(‘LUAS = ‘,LUAS); • READLN; • END. OUTPUT STATEMENT KENDALI PASCAL • VAR • NAMA : STRING[20]; • KET : STRING[10]; • NILAI : INTEGER; • BEGIN • WRITE(‘NAMA = ‘ );READLN(NAMA); • WRITE(‘NILAI = ‘ );READLN(NILAI);
  11. 11. • IF NILAI >= 60 THEN WRITELN(‘LULUS’) • ELSE WRITELN (‘GAGAL’); • READLN; • END. OUTPUT PROGRAM CASE…OF • USES CRT; • VAR • HK, HPL, POT, TOTAL, JUMLAH : INTEGER; • BEGIN • WRITE(‘HARGA KOMPUTER = ‘);READLN(HK); • WRITE(‘HARGA PRODUK LAIN = ‘);READLN(HPL); • JUMLAH := HK+HPL; • WRITELN(‘JUMLAH = RP ‘,JUMLAH); • CASE TOTAL OF • 1000..2900 : POT := 100;
  12. 12. • 3000..5900 : POT := 200; • 6000..10000 : POT := 300; • END; • WRITELN (‘POTONGAN = RP ‘,POT); • TOTAL := JUMLAH – POT • WRITELN (‘TOTAL = RP ‘,TOTAL); • READLN; • END. OUTPUT

×