# C Program to Multiply any Two3 X 3 Matrices

## C Program to Multiply Two 3 X 3 Matrices

This page has a C Program to Multiply any Two 3 X 3 Matrices. It is clear that, this C program will Multiply any Two 3 X 3 Matrices. To multiply any two matrices, the number of columns of the first matrix must be equal to the number of rows  of the the second matrix. If the size of A matrix is (3 x 4), and the size of B matrix is (4 x 2), then the two matrices can be multiplied. If the size of A matrix is (3 x 2), and the size of B matrix is (4 x 2), then the two matrices can not be multiplied. For multiplying any two matrices, the two matrices must be compatible. The below given C program will find the product (Multiply) of any Two 3 X 3 Matrices. Kindly check out the program to Multiply any Two 3 X 3 Matrices. The Questions for the matrix multiplication program can be . . .

1). C program to Multiply any Two 3 X 3 Matrices.

2). C program to find the product of any Two 3 X 3 Matrices.

3). C program to Multiply one 3 x 3 matrix with other on same size.

4). C program to find the product of any Two Matrices with size 3 x 3.

5). C program to find the product of Two 3 X 3 Matrices.

6). C program to find the product of Two Matrices.

7). C program to multiply Two 3 X 3 Matrices.

8). C program to multiply Two Matrices.

### Matrix multiplication Program

#include<stdio.h>
int main(){
int mat31, mat32, mult;
int i, j, k;
printf("\n Enter the First Matrix elements : \n"); // Read 1st Matrix
for (i = 1; i <= 3; i++){
for (j = 1; j <= 3; j++){
scanf("%d", &mat31[i][j]);
}
}
printf("\n Enter the Second Matrix elements : \n"); // Read 2nd Matrix
for (i = 1; i <= 3; i++){
for (j = 1; j <= 3; j++){
scanf("%d", &mat32[i][j]);
}
}
printf("\n The First Matrix :  \n\n"); // Print 1st Matrix
for (i = 1; i <= 3; i++){
for (j = 1; j <= 3; j++){
printf("\t %d ", mat31[i][j]);
}
printf("\n");
}
printf("\n The Second Matrix :  \n\n"); // Print 2nd Matrix
for (i = 1; i <= 3; i++){
for (j = 1; j <= 3; j++){
printf("\t %d ", mat32[i][j]);
}
printf("\n");
}

// . . . The two matrices have been multipled here . . .

for (i = 1; i <= 3; i++){
for (j = 1; j <= 3; j++){
mult[i][j] = 0;
for (k = 1; k <= 3; k++){
mult[i][j] = mult[i][j]+ mat31[i][k] * mat32[k][j];
}
}
}

// . . . Product of the given two Matrices is displayed in Matrix form . . .

printf("\n\n The Resultant of  Matrix Multiplication is \n\n");
for (i = 1; i <= 3; i++){
for (j = 1; j <= 3; j++){
printf("\t%d", mult[i][j]);
}
printf("\n");
}
return (0);
}

Enter the First Matrix elements :
2      2      2      2      2      2      2      2      2
Enter the Second Matrix elements :
2      2      2      2      2      2      2      2      2

The First Matrix :

2           2           2

2           2           2

2           2           2

The Second Matrix :

2           2           2

2           2           2

2           2           2

The Resultant of  Matrix Multiplication is

12           12           12

12           12           12

12           12           12

Related Popular Posts:

*  Write a c program to check whether a given number is prime number or not?

*  Write a C program to find the prime numbers between 1 and 100

*  Write a C program to display the prime numbers between a range ?

*  Write a C program to find the prime numbers between a range using while loop?

*  Write a C program to find the sum of prime numbers between a range

About Er. T.Tharesh Kumar

I am a Professor and Head of Department of Computer Science in an Arts and Science College. I have designed this website to provide solved example programs of different categories for all the school and college going students to learn C language deeply, and to practice Interview based Multiple Choice (Objective Type) questions and answers.