program matriks;
uses wincrt;
const
baris=4;
kolom=4;
type
matrix= array [1..baris,1..kolom] of integer;
var
A,B,C:matrix;
procedure isimatriks;
var i,j:integer;
begin
writeln('Matriks 1');
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write('masukkan baris ke-',i,', kolom ke-',j,' :');readln(A[i,j]);
end;
end;
end;
procedure isimatriks2;
var i,j:integer;
begin
writeln('Matriks 2');
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write('masukkan baris ke-',i,', kolom ke-',j,' :');readln(B[i,j]);
end;
end;
end;
procedure cetakmatriks;
var i,j:integer;
begin
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write(' ',A[i,j]);
end;
writeln;
end;
end;
procedure cetakmatriks2;
var i,j:integer;
begin
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write(' ',B[i,j]);
end;
writeln;
end;
end;
procedure tambah;
var i,j:integer;
begin
for i:=1 to 4 do begin
for j:=1 to 4 do begin
C[i,j]:=A[i,j]+B[i,j];
write(' ',C[i,j]);
end;
writeln;
end;
end;
begin
isimatriks;
clrscr;
isimatriks2;
clrscr;
writeln('MATRIKS 1');
cetakmatriks;writeln;
writeln('MATRIKS 2');
cetakmatriks2;writeln;writeln('MATRIKS 3');
tambah;
end.
uses wincrt;
const
baris=4;
kolom=4;
type
matrix= array [1..baris,1..kolom] of integer;
var
A,B,C:matrix;
procedure isimatriks;
var i,j:integer;
begin
writeln('Matriks 1');
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write('masukkan baris ke-',i,', kolom ke-',j,' :');readln(A[i,j]);
end;
end;
end;
procedure isimatriks2;
var i,j:integer;
begin
writeln('Matriks 2');
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write('masukkan baris ke-',i,', kolom ke-',j,' :');readln(B[i,j]);
end;
end;
end;
procedure cetakmatriks;
var i,j:integer;
begin
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write(' ',A[i,j]);
end;
writeln;
end;
end;
procedure cetakmatriks2;
var i,j:integer;
begin
for i:=1 to 4 do begin
for j:=1 to 4 do begin
write(' ',B[i,j]);
end;
writeln;
end;
end;
procedure tambah;
var i,j:integer;
begin
for i:=1 to 4 do begin
for j:=1 to 4 do begin
C[i,j]:=A[i,j]+B[i,j];
write(' ',C[i,j]);
end;
writeln;
end;
end;
begin
isimatriks;
clrscr;
isimatriks2;
clrscr;
writeln('MATRIKS 1');
cetakmatriks;writeln;
writeln('MATRIKS 2');
cetakmatriks2;writeln;writeln('MATRIKS 3');
tambah;
end.
0 comments:
Post a Comment