C Program For Matrix Multiplication
Algorithm For Matrix Multiplication
1 Step: START.
2 Step: Enter row and column of matrix A.
3 Step: Similarly Enter for Second Matrix B.
4 Step: Enter the elements of Matrix A.
5 Step: Similarly Enter elements of Matrix B.
6 Step: Print elements of Matrix A and B in Matrix form.
7 Step: Set an Outer loop for the row.
8 Step: Set Inner loop for the column.
9 Step: Now Multiply first(A) and second(B) matrix and store in third matrix C.
10 Step: Now print the final Matrix.
11 Step: STOP.
There are different methods to do Matrix Multiplication we will see it one by one.
1. C program for Matrix Multiplication
In this program first, we will ask the user how many rows and columns you want for matrix A and B then the program will ask the user to enter the elements and then the compiler will print the multiplication of Matrix A and B in Matrix C.
Output:


Working of Matrix Multiplication:
At first, we initialize the variables and array in main and then ask the user for rows and columns for Matrix A and Matrix B.
When the user enters the rows and columns then compiler asks to enter the elements for Matrix A and Matrix B.Then matrix addition is done and the addition is stored in third matrix C.
Finally the matrix is printed on the screen.
2. Scalar Matrix Multiplication
In this program, the compiler asks the user to enter row and column for matrix and then the user enters the elements. After the elements are entered the compiler asks to enter the scalar(the number which will be multiplied with the entered matrix).
Now the program performs its operation and prints the final matrix.
Output:

3. Multiplication of Matrix Using Function
Output:

3. Multiplication of Square Matrix
In this program, the elements are declared in the program.
Output:

4. Multiplication of Square Matrix
Output:

Post a Comment