{*****************************************
* Program 1.1. (PROG1-1.PAS) *
* Contoh program dengan sebuah prosedur *
* dan cara memanggilnya *
*****************************************}
program CONTOH; {* nama program *}
uses crt; {* deklarasi piranti *}
const Ukuran = 5; {* deklarasi konstanta *}
type Tabel = array[1..Ukuran,1..Ukuran] of integer;
{* Deklarasi perubah global *}
var Matrix : Tabel;
{* Prosedur *}
procedure BACA_MATRIX (var Mat : Tabel; N : integer);
var I, J : integer; {* perubah lokal *}
begin {* prosedur *}
for I := 1 to N do
for J := 1 to N do
read(Mat[I,J])
end; {* prosedur BACA_MATRIX *}
{* Prosedur Lain *}
procedure CETAK_MATRIX (Mat : Tabel; N : integer);
var I, J : integer; {* perubah lokal *}
begin {* prosedur *}
for I := 1 to N do
begin
for J := 1 to N do
write(Mat[I,J]:8);
writeln;
end;
end; {* prosedur CETAK_MATRIX *}
begin {* program utama *}
{* Memanggil prosedur *}
BACA_MATRIX(Matrix, Ukuran);
CETAK_MATRIX(Matrix, Ukuran)
end. {* program utama *}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment