Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

Latihan ARRAY, RECORD dan WITH

Berikut merupakan latihan menggunakan Array, Record dan statemen With :

TYPE
Barang = Record
Kode     : String[5]   ;
Nama     : Sring[20]  ;
Jumlah    : Integer      ;
Harsat     : Longint     ;
END;

VAR
RecBrg  : Array [1..40] of Barang  ;
Lagi     : Char;
i, J     : Integer;

BEGIN
i:=0    ; J := 0 ;
{  Untuk Menginputkan Data  Barang}

REPEAT
Inc(i)
Write(‘Kode Barang     :’);  Readln(RecBrg[i].Kode);
Write(‘Nama        :’);  Readln(RecBrg[i].Nama);
Write(‘Jumlah        :’);  Readln(RecBrg[i].Jumlah);
Write(‘Harga satuan     :’);  Readln(RecBrg[i].Harsat);
Write(‘Ada lagi [Y/T]    : ‘); Lagi := Readkey ;
Until Lagi In['T','t'] ;

{  Menampilkan Data  Barang   }
Writeln(‘-------------------------------------------------------------’);
Writeln(‘No. Kode  Nama                         Jumlah     Harga ’);
Writeln(‘-------------------------------------------------------------’);
For J := 1 To i  Do
Begin
With RecBrg[ J ] Do
Begin
Writeln( i:3, Kode:6, Nama:25, Jumlah:4, Harsat:9 ) ;
End ;
End ;
Writeln(‘-------------------------------------------------------------’);

End.

Filed under: Pemrograman Pascal,

Terima kasih telah memberikan komentar anda.

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

Archives Per Tahun

Sponsored

C&C Online Shop

Blog Stats

  • 355,909 sejak 12 Jan 2011

User’s Online


My Music

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 223 other followers

March 2011
M T W T F S S
« Feb   Apr »
 123456
78910111213
14151617181920
21222324252627
28293031  
%d bloggers like this: