Translate to your languages

Selamat Datang . Suatu kehormatan bagi saya atas kunjungan ini. Saya sangat berharap kunjungan berikutnya.

03 Desember 2008

ARRAY DIMENSI 1 & 2

ARRAY

Array Dimensi 1 ( I/O )

NO

NAMA

1

Muhammad

2

Zaidhan

3

Nail

4

Soni

5

Sotix


Program Contoh_Array_Input;

uses wincrt;

Var

Nama : array[1..5] of string[25];

i : integer;

Begin

for i:=1 to 5 do

Begin

readln(Nama[i]);

writeln('====================');

end;

for i:=1 to 5 do

Begin

Writeln(Nama[i]);

end;

end.

Array Beragam( I/O )

NO

NIM

NAMA

NILAI UTS

NILAI UAS

1

109008250

Muhammad

80

70

2

109008251

Zaidhan

70

80

3

109008252

Nail

60

70

4

109008253

Soni

80

80

5

109008254

Sotix

60

60

Program Contoh_Deklarasi_Array_Beragam;

Uses wincrt;

Var

NIM : array[1..2] of string[10];

Nama : array[1..2] of string[20];

Nilai_1 : array[1..2] of byte;

Nilai_2 : array[1..2] of byte;

i : integer;

Begin

For i := 1 to 2 Do

Begin

Write('NIM = '); readln(NIM[i]);

Write('Nama = '); readln(Nama[i]);

Write('Nilai UTS = '); readln(Nilai_1[i]);

Write('Nilai UAS = '); readln(Nilai_2[i]);

end;

{cetak varibel array}

Writeln(' =====================================================' );

Writeln(' NIM NAMA NILAI UTS NILAI UAS ' );

Writeln(' =====================================================' );

For i:= 1 to 2 do

Begin

Writeln(NIM[i]:

end;

end.

Array Dimensi 2( I/O )

NO

NILAI UTS

NILAI UAS

1

80

70

2

70

80

3

60

70

Program Deklarasi_Array_Dua_Dimensi;

Uses wincrt;

Var

Tabel : Array[1..3,1..2] of Integer;

i,j : Integer;

Begin

Tabel[1,1]:=80;

Tabel[1,2]:=70;

Tabel[2,1]:=70;

Tabel[2,2]:=80;

Tabel[3,1]:=60;

Tabel[3,2]:=70;

For I := 1 to 3 Do

Begin

For J:= 1 to 2 Do

Begin

Writeln('Nilai ',i,',',j,'= ',tabel[i,j]);

End;

End;

End.

Array Matrix( I/O )

Penggunaan array dua dimensi dalam aplikasi penjumlahan matrik :

Program Penjumlahan_Matrik;

Uses winCrt;

Var

Matrik1,Matrik2, Hasil : Array[1..3,1..2] of Integer;

i,j : Integer;

Begin

ClrScr;

{ input matrik ke satu }

Writeln(' Elemen matrik satu');

For i := 1 to 3 Do

Begin

For j := 1 to 2 Do

Begin

Write('Elemen baris -',i,' Kolom -',j,'= ');

Readln(matrik1[i,j]);

end;

End;

{input matrik ke dua}

Writeln('input elemen matrik dua');

For i:= 1 to 3 Do

Begin

For j:= 1 to 2 Do

Begin

Write('Elemen baris -',i,' kolom -',j,'= ');

Readln(matrik2[i,j]);

end;

End;

{proses penjumlahan tiap elemen}

For i := 1 to 3 Do

Begin

For j:= 1 to 2 Do

Begin

Hasil[i,j]:=Matrik1[i,j]+Matrik2[i,j];

end;

end;

{proses cetak hasil}

For i:= 1 to 3 Do

Begin

For j:= 1 to 2 Do

Begin

Write(Hasil[i,j]:6);

end;

Writeln;

End;

End.

3 komentar:

yusuf eye mengatakan...

array itu apa

teddy mengatakan...

salam kenal,, saya baru belajar c++, agar tampilan hurufnya kesamping pake rumus apa ya?? yang sekarang tampilannya kebawah. trimksih

sharing info mengatakan...

ane kagak ngedoong mas bro , , sebner ini yang ane cari ,, :-((((( , tugas kampus menumpuk ..