You are on page 1of 16

program keluaran; uses wincrt; var a, t, l: real; i, N: integer; procedure hitungluassegitiga(alas, tinggi: real; var luas: real); begin

luas:=(alas*tinggi)/2; end; begin write('masukkan jumlah segitiga: '); readln(N); for i:= 1 to N do begin writeln; write('masukkan alas: '); readln(a); write('masukkan tinggi: '); readln(t); hitungluassegitiga(a, t, l); write('luas segitiga: ',l:2:2); end; END.

program bulan; uses wincrt; var tanggal, bulan, tahun : integer; ulang : string; procedure namabulan (var bulan : integer); var nobulan : integer;

begin write ('masukan tanggal : '); read (tanggal); write ('masukan bulan : '); read (nobulan); write ('masukan tahun : '); read (tahun); writeln; write ('Tanggal yang anda inputkan : ' ,tanggal, ' '); case nobulan of 1 : write ('januari '); 2 : write ('februari '); 3 : write ('maret '); 4 : write ('april '); 5 : write ('mei '); 6 : write ('juni '); 7 : write ('juli '); 8 : write ('agustus '); 9 : write ('september '); 10 : write ('oktober '); 11 : write ('november '); 12 : write ('desember '); end; end; begin namabulan (bulan); write ( tahun); end; end.

program jamberikut;

uses wincrt; var jam,menit,detik:longint; j:integer; procedure jamberikutnya(var jam,menit,detik:longint); var totaldetik, sisadetik,sisa: longint; begin totaldetik:= jam*3600 + menit*60 + detik+1; sisa:= totaldetik; jam:= sisa div 3600; sisadetik:= sisa mod 3600; menit:= sisadetik div 60; detik:= sisadetik mod 60; end; BEGIN write('masukkan jam: '); readln(jam); write('masukkan menit: '); readln(menit); write('masukkan detik: '); readln(detik); writeln('jam awal:'); write(jam, ':', menit, ':', detik); jamberikutnya(jam,menit,detik); writeln('jam berikutnya setelah 1 detik: '); write(jam, ':', menit, ':', detik); END.

program Pengolahan_Data; uses wincrt; type larik = array [1..100] of string; larikan = array [1..100] of integer; var H,M :larikan; A : larik; i,no,jumlah,y,z,n,menu:integer; rata:real;

procedure input; begin z:=999; y:=0; i:=0; jumlah:=0; M[i]:=H[i]; while A[i]<> 'berhenti' do begin i:=i+1; write('Nama Mahasiswa: '); readln(A[i]); if A[i]<> 'berhenti' then begin write('Nilai : '); readln(H[i]); end;

jumlah:=jumlah+H[i]; if H[i] > y then begin y:= H[i]; end; if (H[i] < z) and (H[i] >0 )then begin z := H[i]; end; end; n:=i-1; rata:= jumlah/(n); end;

procedure diatasrataan; begin writeln ('rata-rata data : ',rata:2:2); writeln; writeln ('daftar nama yang diatas rata-rata : '); i:=0; while i<>n do begin i:=i+1; if (H[i] > rata) then begin writeln (A[i],' dengan nilai : ',H[i],' '); writeln;

writeln; end; end; end;

procedure dibawahrataan; begin writeln ('daftar nama yang dibawah rata-rata: '); writeln; i:=0; while i<>n do begin i:=i+1; if (H[i] < rata) then begin writeln (A[i],' dengan nilai : ',H[i],' '); end; end; end;

procedure max; begin writeln ('nilai maksimum data tersebut: ',y); i:=0; writeln('yang meraih nilai maksimum adalah: '); while i<>n do begin

i:=i+1; if (H[i] = y) then begin write (A[i],','); end; end; writeln; end;

procedure min; begin writeln('nilai minimum data tersebut: ',z); writeln ('yang meraih nilai minimum adalah: '); i:=0; while i<>n do begin i:=i+1; if (H[i] = z) then begin write (A[i],','); end; end; end;

BEGIN writeln ('=====================================================================');

writeln ('':25 ,'PROGRAM PENGOLAHAN DATA '); writeln; writeln ('':16 ,'Nama : Ogi Jayaprana'); writeln ('':16 ,'NIM : 1006667'); writeln ('====================================================================='); writeln; writeln; writeln; writeln ('':15,' writeln ('':15,' Masukan Nama dan Nilai '); ');

writeln ('Ket: inputkan"berhenti" bila ingin menghentikan inputan data mahasiswa'); writeln; writeln; input; writeln; clrscr; begin repeat writeln; writeln('No Menu Pilihan:'); writeln ('1: Rata-rata, nilai diatas rata-rata dan dibawah rata-rata '); writeln ('2: Nilai maksimum dan minimum dari semua data'); writeln ('3: keluar '); writeln; writeln; writeln('Pilih menu Yang anda inginkan: '); read ( no);

clrscr; if no > 3 then writeln ('':15,'!!!!!maaf pilihan anda salah'); writeln; case no of 1: begin diatasrataan; dibawahrataan; writeln; writeln; end; 2: begin max; min; end; 3: begin menu := 3; writeln(''); writeln(''); writeln('':10,'========================================================='); writeln('':10,'------------Saya Ogi Jayaprana Mengucapkan---------------'); writeln('':10,'----------------------Terima Kasih-----------------------'); writeln('':10,'-----------------Semoga Bermanfaat!!!!-------------------'); writeln('':10,'========================================================='); end;

end; until menu = 3; end; END.

program himpunan_irigab; uses wincrt; const Nmaks=100; type LarikInt = array[1..Nmaks] of integer; var A,B,irisan:larikInt; i,z,nA,nB:integer; himp,jawab,masuk:char; procedure nama; begin writeln('================================================================'); writeln(' PROGRAM MENGECEK KESAMAAN 2 HIMPUNAN ');

writeln('================================================================'); writeln(' writeln(' Nama : Ogi Jayaprana'); NIM : 1006667');

writeln('================================================================'); writeln; writeln; end; Procedure himpunan (himp:char;z:integer; var A:larikint; var nA:integer); var i:integer; begin

i:=0; nA:=0; while z<>999 do begin i:=i+1; A[i] := z; write (himp,i,' = '); readln(z); nA:=nA+1; end; nA:=nA-1; writeln ('Banyak anggota himpunan ',himp,' = ',nA); end; procedure cetakhimpunan(A:larikInt;nA:integer;himp:char); var i:integer; begin write(himp,' = { '); for i:=2 to nA+1 do if i<nA+1 then write(a[i],' , ') else write(a[i]); write(' }'); writeln; end; procedure cekhimpunan(A,B:larikint;nA,nB:integer;var irisan:larikint;var i:integer); var m,n:integer; sama,c : integer; begin

sama:=0; i:=0; for m:=2 to nA+1 do for n:=2 to nB+1 do if A[m]=B[n] then begin sama:=sama+1; i:=i+1; irisan[i] := A[m]; end; if sama<>nA then writeln('himpunan A dan himpunan B berbeda') else writeln('himpunan A dan himpunan B sama'); writeln('nA=',nA,' , nB=',nB); end; procedure irisanhimpunan(irisan:larikint;i:integer); var m:integer; begin write('irisan himpunan A dan B = { '); for m:=1 to i do if m<i then write(irisan[m],' , ') else write(irisan[m]); write(' }'); end;

procedure gabunganhimpunan(A,B,irisan:larikint;nA,nB,i:integer); var gabungan:larikint; m,n,j,sama,samatidak:integer;

begin sama:=0; samatidak:=sama; j:=0; for m:=2 to nA+1 do begin for n:=1 to i do if A[m]=irisan[n] then sama:=sama+1; if samatidak=sama then begin j:=j+1; gabungan[j]:=A[m]; end; samatidak:=sama; end;

sama:=0; samatidak:=sama; for m:=2 to nB+1 do begin for n:=1 to i do if B[m]=irisan[n] then sama:=sama+1; if samatidak=sama then begin j:=j+1; gabungan[j]:=B[m]; end;

samatidak:=sama; end;

write('gabungan himpunan A dan B = { '); for m:=1 to i do if j=0 then if m<i then write(irisan[m],' , ') else write(irisan[m]) else write(irisan[m],' , '); for m:=1 to j do if m<j then write(gabungan[m],' , ') else write(gabungan[m]); writeln(' }'); end; BEGIN repeat nama; writeln('':13,'tekan enter dua kali untuk masuk program'); readln(masuk); clrscr; z:=-999; writeln('masukkan anggota-anggota himpunan A '); writeln('dengan syarat(a1<>a2)'); writeln('inputkan "999" untuk berhenti '); writeln; himp:='A'; himpunan(himp,z,A,nA); writeln; himp:='B';

writeln('masukkan anggota-anggota himpunan B'); writeln('dengan syarat( b1<> b2)'); writeln('inputkan "999" untuk berhenti) : '); writeln; himpunan(himp,z,B,nB); writeln; clrscr; nama; himp:='A'; cetakhimpunan(A,nA,himp); himp:='B'; cetakhimpunan(B,nB,himp); writeln; cekhimpunan(A,B,nA,nB,irisan,i); writeln; irisanhimpunan(irisan,i); writeln; gabunganhimpunan(A,B,irisan,nA,nB,i); writeln; write('ulangi program (y/t) ? '); writeln; readln(jawab ); until jawab='t'; clrscr; writeln; writeln; writeln;

writeln; writeln(''); writeln(''); writeln('':10,'========================================================='); writeln('':10,'------------Saya Ogi Jayaprana Mengucapkan---------------'); writeln('':10,'----------------------Terima Kasih-----------------------'); writeln('':10,'-----------------Semoga Bermanfaat!!!!-------------------'); writeln('':10,'========================================================='); END.