Home

Program PenjumlahanMatriks;

Uses Wincrt ;

Var

   x,y,z   : array [1..10,1..10] of integer ;

   i,j,m,n : integer ;

 

Begin

     write(‘Banyak baris : ‘);

     readln (m);

     write(‘Banyak kolom : ‘);

     readln (n) ;

 

     { Matriks Pertama}

     Writeln (‘Matriks Pertama  :’);

     for i := 1 to m do

         begin

         for j:=1 to n do

             begin

             write(‘Elemen ke ‘,i,’,’,j,’ :’);

             read(x[i,j]);

             end;

         end;

 

 

     {Matriks Kedua }

     Writeln (‘Matriks Kedua : ‘);

     for i := 1 to m do

         begin

         for j:=1 to n do

             begin

             write(‘Elemen ke ‘,i,’,’,j,’ :’);

             read(y[i,j]);

             end;

         end;

 

 

     {Menampilkan Matriks Pertama }

     writeln (‘Matriks Pertama : ‘);

     for i:=1 to m do

         begin

         for j:=1 to n do

                 begin

                 write(x[i,j]: 4);

                 end;

                 writeln;

                 readln;

         end;

 

     {Menampilkan Matriks Kedua }

     writeln (‘Matriks Kedua : ‘);

     for i:=1 to m do

         begin

         for j:=1 to n do

             begin

             write(y[i,j]: 4);

             end;

             writeln;

             readln;

         end;

 

     {Melakukan penjumlahan Matriks Pertama dan Matriks KeDua

     Sekaligus Menampilkan hasilnya Kelayar }

     Writeln (‘Matriks Hasil Penjumlahan : ‘);

     for i:= 1 to m do

         begin

         for j:= 1 to n do

             begin

             z[i,j] := x[i,j] + y[i,j];          

                    begin

                    write(z[i,j]:4);

                    end;

             end;

             writeln;

         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