0% found this document useful (0 votes)
32 views

Procedure Matriks

This Pascal program defines procedures to input elements, add, and display 2x2 matrices. It takes in two user-input matrices, adds them together element-wise, and displays the original matrices and sum matrix. The main procedures are InputMatriks to input a matrix, JumlahMatriks to add matrices, and TampilkanMatriks to display a matrix.

Uploaded by

satrio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Procedure Matriks

This Pascal program defines procedures to input elements, add, and display 2x2 matrices. It takes in two user-input matrices, adds them together element-wise, and displays the original matrices and sum matrix. The main procedures are InputMatriks to input a matrix, JumlahMatriks to add matrices, and TampilkanMatriks to display a matrix.

Uploaded by

satrio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Muhammad Satrio Bamaputra

1012297
1KA08
Tugas 5
Program penjumlahan matriks 2x2
1.
program PenjumlahanMatriks;

type
Matriks = array[1..2, 1..2] of Integer;

var
matriks1, matriks2, hasil: Matriks;
i, j: Integer;

procedure InputMatriks(var matriks: Matriks);


begin
for i := 1 to 2 do
begin
for j := 1 to 2 do
begin
write('Masukkan elemen matriks [', i, '][', j, ']: ');
readln(matriks[i, j]);
writeln();
end;
end;
end;

procedure JumlahMatriks(var matriks1, matriks2, hasil: Matriks);


begin
for i := 1 to 2 do
begin
for j := 1 to 2 do
begin
hasil[i, j] := matriks1[i, j] + matriks2[i, j];
end;
writeln();
end;
end;

procedure TampilkanMatriks(matriks: Matriks; judul: string);


begin
writeln(judul);
for i := 1 to 2 do
begin
for j := 1 to 2 do
begin
write(matriks[i, j]:4);
end;
writeln;
end;
end;

begin
writeln();
writeln('== Penjumlahan Matriks 2x2 ==');

writeln('Masukkan elemen-elemen matriks 1 : ');


InputMatriks(matriks1);

writeln('Masukkan elemen-elemen matriks 2 : ');


InputMatriks(matriks2);

JumlahMatriks(matriks1, matriks2, hasil);

TampilkanMatriks(matriks1, 'Matriks Pertama :');


TampilkanMatriks(matriks2, 'Matriks Kedua :');
TampilkanMatriks(hasil, 'Hasil Penjumlahan :');

readln;
end.

Output

You might also like