Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
961 B
6
Indexable
Never
Program JumlahMatriks;
uses crt;

const
  Jbaris = 3;
  Jkolom = 3;

type
  Matriks23 = array [1..Jbaris, 1..Jkolom] of integer;

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

begin
  clrscr;

  { Mengisikan matriks A }
  writeln('Matriks 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;

  { Mengisikan matriks B }
  writeln('Matriks 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;
  writeln;

  { Melakukan penjumlahan matriks A dan B sekaligus menampilkan hasilnya ke layar }
  writeln('Hasil Penjumlahan');
  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;

  readln;
end.
Leave a Comment