This program multiplies two matrices which will be entered by the user, And also enter the range of matrix by the user.
C programming code
#include<stdio.h>
#include<conio.h>
{
int a[3][3], b[3][3], m[3][3], i, j, k, n, sum[3][3];
clrscr();
printf("\n Enter the number of same rows and columns of first matrix ");
scanf("%d",&n);
printf("\n Enter the elements of first matrix\n");
for ( i = 0 ; i < n ; i++ )
for ( j = 0 ; j < n ; j++ )
scanf("%d",&a[i][j]);
printf("\n Enter the elements of second matrix\n");
for ( i = 0 ; i < n ; i++ )
for ( j = 0 ; j < n ; j++ )
scanf("%d",&b[i][j]);
for ( i = 0 ; i < n ; i++ )
{
for ( j = 0 ; j < n ; j++ )
{
sum[i][j]=0;
for ( k = 0 ; k < n ; k++ )
{
sum[i][j] = sum[i][j] + a[i][k]*b[k][j];
}
}
}
printf("\n Product of entered matrices:-\n");
for ( i = 0 ; i < n ; i++ )
{
for ( j = 0 ; j < n ; j++ )
printf("%d\t",m[i][j]);
printf("\n");
}
getch();
}
Output:-
