Pemrograman Pascal; Mengambil Nilai Array

Contoh skrip pemrograman pascal untuk mengambil nilai array. Tampilannya akan menjadi seperti gambar berikut:

mengenali nilai array

mengenali nilai array

User diminta memasukkan 4 nilai bertipe integer. Kemudian masukkan data array yang ingin dilihat, tekan enter.

program mengambil_nilai_array;
uses wincrt;
label ulang, fin;
var
   x:array[1..4] of integer;
   i, j :integer; c : char;

begin
ulang:
clrscr;

for i:=1 to 4 do
begin
     write ('data ke ',i,' = ');readln(x[i]);
end;
write('data ke ? ');readln(j); writeln('data ke ',j,' adalah ',x[j]);
writeln;
write(' LAGI [Y/N] ? ');readln(c);
case c of
'y','Y' : goto ulang;
'n','N' : goto fin;
end;
fin:
writeln('--- SELESAI ---');
end.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s