Sabtu, 17 Januari 2009

Membuat Program Penjumlahan Matriks

program penjumlahan_matriks;
uses wincrt;
var
matriks1,matriks2,matriks3 :array[1..4,1..4] of integer;
i,j:integer;
begin
writeln(' ============================================= ');
writeln(' Penjumlahan MATRIKS ');
writeln(' ============================================= ');
begin
writeln(' Matriks I ');
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
write(' Elemen (',i,',',j ,') = ');readln(matriks1[i,j]);
end;
writeln;
end;
end;
begin
writeln;
writeln(' Matriks I ');
writeln;
for i:= 1 to 4 do
begin
for j:= 1 to 4 do
begin
write(matriks1[i,j]:7);
end;
writeln;
writeln;
end;
writeln;
writeln;
end;
begin
writeln(' Matriks II ');
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
write(' Elemen (',i,',',j ,') = ');readln(matriks2[i,j]);
end;
writeln;
end;
readln;
end;
begin
writeln;
writeln(' Matriks II ');
writeln;
for i:= 1 to 4 do
begin
for j:= 1 to 4 do
begin
write(matriks2[i,j]:7);
end;
writeln;
writeln;
end;
writeln;
writeln;
readln;
end;
begin
writeln(' Hasil penjumlahan matriks tersebut');
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
matriks3[i,j]:=matriks1[i,j]+matriks2[i,j];
write(' ELemen (',i,',',j ,') = ',matriks3[i,j]);
end;
writeln;
end;
end;
begin
writeln;
writeln(' Matriks Hasil ');
writeln;
for i:= 1 to 4 do
begin
for j:= 1 to 4 do
begin
write(matriks3[i,j]:7);
end;
writeln;
writeln;
end;
writeln;
writeln;
end;
writeln(' ============================================= ');
writeln(' SELESAI ');
writeln(' ============================================= ');
end.

Tidak ada komentar:

Posting Komentar

Kirim Komentar Anda
(Send Your Comment)