" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Uses Crt;
Var Tabel : Array[1..3,1..2] of Integer;
i,j : Integer;
Begin
ClrScr;
Tabel[1,1]:=1;
Tabel[1,2]:=2;
Tabel[2,1]:=3;
Tabel[2,2]:=4;
Tabel[3,1]:=5;
Tabel[3,2]:=6;
For I := 1 to 3 Do Begin For J:= 1 to 2 Do Begin Writeln('Elemen ',i,',',j,'= ',tabel[i,j]);
End;
End;
Readln;
End.
Contoh program Array dalam record:
Type barang= RECORD
nmbrg:string[20];
jmlbrg:array[1..3]of byte;
hrgbrg:real;
total:real;
end;
var jual:barang;
tbarang, i:integer;
Begin
clrscr;
write(‘Nama Barang :’);readln(jual.nmbrg);
for i:=1to 3 do
begin
write(‘Jumlah barang ’,I,’ : ’);readln(jual.jmlbrg[i]);
tbarang:=tbarang+jual.jmlbrg[i];
end;
write(‘Harga barang :’);readln(jual.hrgbrg);
jual.total:=tbarang*jual.hrgbrg;
writeln(‘Total Harga Barang = ‘, jual.total:10:2);
end.