# Pascal Program For Matrix Multiplication

Pascal Program For Matrix Multiplication: This is a Pascal program to Multiply arrays A[i , j] and B[i, j].

Each element of the resulting matrix is multiplied by 1/4, and the result is displayed in a new Array.

### What is an Array?

An array consists of rows and columns, and in programming, it is a data type used to hold a range of data of the same type.

The same data type here could be integer, string, Boolean, or real.

### Logic of The Program

The Arrays used in this computation have two rows and two columns respectively, hence the resulting matrix or array must also be a 2 x 2 matrix.

First, the two arrays are multiplied together, where a row is used to multiply a column.

After their multiplication which is given to a new Array C, the result in Array C is multiplied by 1/4 to give the final matrix D whose result is displayed as an output to the user.

As with most looping Pascal Programs, here we've implemented the FOR DO control statement, which ensures that we're working with a 2 x 2 Matrix.

The FOR DO structure in Pascal Programming is given by:

FOR variable:= startvalue TO endvalue Do
Statement(s)

### Program Code

Program begn;
Var
A, B, C, D : Array [1..2,1..2] of real;
I, j: integer;

Begin
For i:= 1 to 2 do
For j:= 1 to 2 do
Begin
Readln (A[i, j]);
End;

Begin
For i:= 1 to 2 do
For j:= 1 to 2 do
Readln (B[i, j]);
End;

Begin
For i:= 1 to 2 do
For j:= 1 to 2 do
C[i, j]:= A[i, j] * B[i, j];
End;

Begin
For i:= 1 to 2 do
For j:= 1 to 2 do
D[i, j]:= 1/4 * C[i, j];
End;

Begin
For i:= 1 to 2 do
For j:= 1 to 2 do
Writeln (D[i, j]);
Readln;
End;
End.

### Conclusion

Following the same logic in this Pascal Program For Matrix Multiplication, you can multiply numbers in a 3 x 2 array and do many more array computations in Pascal.

Also Read:

BASIC Program For Sum of Numbers Using IF Then Statement
Pascal Arithmetic Program Using IF THEN statement
Pascal Program to Create and Save Records in a Textfile
Pascal program To Calculate Area of a Triangle
Pascal Program of Matrix Multiplication
Pascal Program to Find The Average Of Only Positive Numbers Using While Do loop

#### Author: Grace Joseph

Tech blogger, SEO expert, cryptocurrency enthusiast, and freelancer are the terms that describe me. I'll rather write a thousand words than speak hundred words, and that describes my passion as a content creator.