Fungsi : Menjumlahkan dua matriks 3x3 yang diinputkan
Hint: Masukan nilai matriks di tiap-tiap baris dan kolom.
Screen Shot :
uses crt;
var m1,m2,mp:array[1..10,1..10] of integer;
i,j,k,l:integer;
begin
{Menginput nilai matriks}
writeln('Matriks ke 1');
for i:=1 to 3 do
for j:=1 to 3 do
begin
write('m1[',i,',',j,'] : ');readln(m1[i,j]);
end;
writeln;
writeln('Matriks ke 2');
for i:=1 to 3 do
for j:=1 to 3 do
begin
write('m2[',i,',',j,'] : ');readln(m2[i,j]);
end;
writeln;
{jumlahkan}
begin
for i:=1 to 3 do
for j:=1 to 3 do
begin
mp[i,j]:=m1[i,j]+m2[i,j];
end;
{lukis hasil penjumlahan}
writeln('Hasil Penambahan = ');
writeln;
for i:=1 to 3 do
begin
writeln;
for j:=1 to 3 do
write(mp[i,j],' ');
end;
readln;
end;
end.
Post a Comment