#include<stdio.h>
#include<conio.h>
int main(){
int a[3][3],b[3][3],c[3][3];
int i,j,k;
int temp = 0;
printf("Plz., enter the values of first matrix: ");
for ( i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
printf("a[%d][%d] = ",i,j);
scanf("%d",&a[i][j]);
}
}
for ( i = 0; i < 3; i++)
{
printf("| ");
for ( j = 0; j < 3; j++)
{
printf("%d ",a[i][j]);
}
printf(" | \n");
}
printf("Plz., enter the values of second matrix: ");
for ( i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
printf("b[%d][%d] = ",i,j);
scanf("%d",&b[i][j]);
}
}
for ( i = 0; i < 3; i++)
{
printf("| ");
for ( j = 0; j < 3; j++)
{
printf("%d ",a[i][j]);
}
printf(" | \n");
}
printf("The multiplication of the given matrix is: ");
for ( i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
for ( k = 0; k < 3; k++)
{
temp = 0;
temp += a[i][k]*b[k][j];
}
c[i][j] += temp;
}
}
for ( i = 0; i < 3; i++)
{
printf("| ");
for ( j = 0; j < 3; j++)
{
printf("%d ",c[i][j]);
}
printf(" | \n");
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter