Terjemahan/Translator

Thursday, November 7, 2013

Program Array

 Contoh Program Pascal Array:

Program Contoh_Deklarasi_Array_Beragam;
Uses Crt;
Var
NPM : array[1..20] of string[10];
Nama : array[1..20] of string[25];
Nilai : array[1..20] of real;
Umur : array[1..20] of byte;
banyak,i : integer;
Begin
ClrScr;
Write('Isi berapa data array yang diperlukan :');Readln(banyak);
For i := 1 to banyak Do
Begin
Write('NPM =');Readln(NPM[i]);
Write('Nama =');readln(Nama[i]);
Write('Nilai=');readln(Nilai[i]);
Write('Umur =');readln(Umur[i]);
End;
{cetak varibel array}
Writeln('NPM NAMA NILAI UMUR ');
For i:= 1 to banyak Do
Begin
Writeln(Npm[i]:10,Nama[i]:25,Nilai[i]:3:2,' ',Umur[i]:3);
End;
Readln;
end.

No comments:

Post a Comment