Exploring the Ocean of Science

Assalamualaikum…

Yang satu ni versi terbaru yang lebih lengkap dari penjumlahan matriks yang telah dibahas sebelumnya, pada program ini diberi sentuhan menu dan tambahan fungsi untuk pengurangan matriks. Met Mencoba ^_^

Program menu_matriks;
uses crt;
Type
matrix = array[1..2,1..3] of integer;
var
matrixa,matrixb : matrix;
p : byte;

{—-UNTUK MENU—–}

procedure menu(var pil:byte);
begin
clrscr;
Writeln(‘Menu Matrix’);
Writeln(‘ 1.Penjumlahan’);
Writeln(‘ 2.Pengurangan’);
Writeln(‘ 3.Exit’);
Write(‘Pilihan Anda : ‘);
Readln(pil);
end;

{—-UNTUK INPUT—-}

procedure Input(var i:matrix);
var x,z : integer;
begin
for z:=1 to 2 do
begin
for x:=1 to 3 do
begin
Write(‘Inputkan Matrix[‘,z,’ , ‘,x,’] : ‘);
Readln(i[z,x]);
end;
end;
end;

{—-UNTUK MENAMPILKAN MATRIX—-}
procedure Tampil(var i:matrix);
var x,z : integer;
begin
writeln;
for z:=1 to 2 do
begin
for x:=1 to 3 do
begin
Write(i[z,x]:4);
end;
Writeln;
end;
end;

{—-UNTUK PROSES PENJUMLAHAN—-}
procedure Jumlah(var a,b:matrix);
var k : matrix;
x,z : integer;
begin
writeln;
writeln(‘Hasil Penjumlahan Matriks’);
for z:=1 to 2 do
begin
for x:=1 to 3 do
begin
k[z,x] := a[z,x] + b[z,x];
write(k[z,x]:4);
end;
writeln;
end;
end;

{—-UNTUK PROSES PENGURANGAN—-}
procedure Kurang(var a,b:matrix);
var k : matrix;
x,z : integer;
begin
writeln;
writeln(‘Hasil Pengurangan Matriks’);
for z:=1 to 2 do
begin
for x:=1 to 3 do
begin
k[z,x] := a[z,x] – b[z,x];
write(k[z,x]:4);
end;
writeln;
end;
end;

{—-PROGRAM UTAMA—-}
begin
while p 3 do
begin
menu(p);
clrscr;
case p of
1: begin
writeln(‘Penjumlahan Matriks’);
writeln(‘Matriks I’);
Input(matrixa);
writeln;
writeln(‘Matriks II’);
Input(matrixb);
writeln;

clrscr;
Write(‘Matriks I’);
Tampil(matrixa);
writeln;
Write(‘Matriks II’);
Tampil(matrixb);
jumlah(matrixa,matrixb);
Readln;
end;
2: begin
write(‘Pengurangan Matriks’);
writeln(‘Matriks I’);
Input(matrixa);
writeln;
writeln(‘Matriks II’);
Input(matrixb);
writeln;

clrscr;
Write(‘Matriks I’);
Tampil(matrixa);
writeln;
Write(‘Matriks II’);
Tampil(matrixb);
kurang(matrixa,matrixb);
Readln;
end;
end;
end;
end.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: