PERKALIAN MATRIKS DENGAN PASCAL

program perkalian_matriks;

uses wincrt;

var

a,b,c:array[1..25,1..25] of real;

d,e,f,i,j,k:byte;

begin

clrscr;

gotoxy(30,1);writeln(‘===========================’);

gotoxy(30,2);writeln(‘”Program Perkalian Matriks”‘);

gotoxy(30,3);writeln(‘===========================’);

writeln;

write(‘jumlah baris matrik pertama = ‘);readln(d);

write(‘jumlah kolom matrik pertama/baris matrik kedua = ‘);readln(e);

write(‘jumlah kolom matrik kedua = ‘);readln(f);

writeln;

writeln(‘matrik yang pertama’);

for i:=1 to d do

begin

for j:=1 to e do

begin

write(‘nilai[‘,i,’,’,j,’]?’);readln(a[i,j]);

end;

writeln;

end;

writeln(‘matrik yang kedua’);

for i:=1 to e do

begin

for j:=1 to f do

begin

write(‘nilai[‘,i,’,’,j,’]?’);readln(b[i,j]);

end;

writeln;

end;

for i:=1 to d do

begin

for j:=1 to f do

begin

c[i,j]:=0;

for k:=1 to e do

c[i,j]:=c[i,j]+a[i,k]*b[k,j];

end;

end;

clrscr;

writeln(‘matrik yang pertama’);

for i:=1 to d do

begin

write(‘|’);

for j:=1 to e do

begin

write(a[i,j]:9:2);

end;

write(‘|’);

writeln;

end;

writeln(‘matrik yang kedua’);

for i:=1 to e do

begin

write(‘|’);

for j:=1 to f do

begin

write(b[i,j]:9:2);

end;

write(‘|’);

writeln;

end;

writeln(‘hasil dari perkalian matrik : ‘);

writeln;

for i:=1 to d do

begin

write(‘|’);

for j:=1 to f do

write(c[i,j]:9:2);

write(‘|’);

writeln;

end;

end.

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

w

Connecting to %s

%d blogger menyukai ini: