(Copyright - Java[at]Saindra - 2010)
Penjumlahan Matriks Ordo 3x3
- Posted: 10/08/2009 03:26:00 pm
- |
- Author: Java[at]Saindra
- |
- Filed under: Pemrograman Terstruktur
PASCAL SOURCE :
program PenjumlahanMatrik;
uses wincrt;
var
matriks1, matriks2, matriks_hasil: array[1..3, 1..3] of integer;
i, j: integer;
begin
Randomize;
for i :=1 to 3 do {hanya menjalankan for saja}
for j:=1 to 3 do {melakukan 2 statement, makanya harus dikelompokkan dengan begin dan end}
begin
matriks1[i,j]:=random(5);
matriks2[i,j]:=random(5);
end;
writeln('Matriks 1');
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
write(matriks1[i,j]:5);
end;
writeln;
end;
writeln('Matriks 2');
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
write(matriks2[i,j]:5);
end;
writeln;
end;
for i:=1 to 3 do
for j:=1 to 3 do
begin
matriks_hasil[i,j]:=matriks1[i,j] + matriks2[i,j];
end;
writeln('Hasil penjumlahan matriks 1 dan matriks 2');
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
write(matriks_hasil[i,j]:5);
end;
writeln;
end;
end.
OUTPUT :
NOTE :
Perulangan
i=1
j=1
(i,j)=[1,1]
j=2
(i,j)=[1,2]
j=3
(i,j)=[1,3]
i=2
j=1
(i,j)=[2,1]
j=2
(i,j)=[2,2]
j=3
(i,j)=[2,3]
i=3
j=1
(i,j)=[3,1]
j=2
(i,j)=[3,2]
j=3
(i,j)=[3,3]
This post powered by :
copyright - javaatsaindra.blogspot.com - OSC
Semua content dari blog ini bersifat open-source. Silahkan memperbanyak, menyebarluaskan, mencetak, dan memodifikasi asalkan tetap mencantumkan author dan alamat blog ini. Terimakasih. DONT BE A PLAGIATOR!!
- Copyright . 2008-2011 . Java[at]Saindra . OpenSourceContent
- Back To Top
- Home
Post a Comment