menjumlahkan matrik dengan metode procedure

program matrik_dua_dimensi;

uses wincrt;
const
  jbaris=2;
  jkolom=2;

type
matrik = array [1..jbaris,1..jkolom] of integer;

var
A,B,C: matrik;
j,k  : integer;

procedure baca_matrik ( var A:matrik; jbaris,jkolom: integer);
begin
{mengisi matrik A}
writeln(‘Matrik A’);
for j:= 1 to jbaris  do begin
    for k:= 1 to jkolom do begin
       write(‘A[‘,j,’,’,k,’]=’); readln(A[j,k]);
    end;
    writeln;
    end;
writeln;
(*mengisi matrik B *)
writeln(‘Matrik B’);
for j:= 1 to jbaris do begin
   for k:= 1 to jkolom do begin
     write(‘B[‘,J,’,’,K,’]=’);readln(b[j,k]);
   end;
   writeln;
   end;
end;
procedure cetak_matrik ( A,B,C:matrik; jbaris,jkolom:integer);
begin
writeln (‘Hasil penjumlahan matrik A dan B ‘);
for j:= 1 to jbaris do begin
    for k:= 1 to jkolom do begin
    c[j,k]:= a[j,k]+b[j,k];
    writeln(‘C[‘,j,’,’,k,’]=’,c[j,k]);
    end;
writeln;
end;
end;
begin
writeln (‘ penjumlahan matrik ‘);
baca_matrik (a,jbaris,jkolom);
cetak_matrik ( a,b,b,jbaris,jkolom);
end.

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s