- buatlah program untuk penjumlahan dua buah matriks !
Program penjumlahan_matriks; uses wincrt; Type matrix = array[1..2,1..3] of integer; var matrixa,matrixb : matrix; procedure Input(var x:matrix); var i,j : integer; begin for i:=1 to 2 do begin for j:=1 to 3 do begin Write('Inputkan Matrix[',i,' , ',j,'] : '); Readln(x[i,j]); end; end; end; procedure Tampil(var x:matrix); var i,j : integer; begin for i:=1 to 2 do begin for j:=1 to 3 do begin Write(x[i,j]:4); end; Writeln; end; end; procedure Jumlah(var a,b:matrix); var c : matrix; i,j : integer; begin writeln; writeln('Hasil Penjumlahan Matriks'); for i:=1 to 2 do begin for j:=1 to 3 do begin c[i,j] := a[i,j] + b[i,j]; write(c[i,j]:4); end; writeln; end; end; begin writeln('Penjumlahan Matriks'); writeln('Matriks I'); Input(matrixa); writeln; writeln('Matriks II'); Input(matrixb); writeln; Writeln('Matriks I'); Tampil(matrixa); writeln; Writeln('Matriks II'); Tampil(matrixb); jumlah(matrixa,matrixb); Readln; end. |
Tidak ada komentar:
Posting Komentar