#include<stdio.h>
int main()
{
int i,j,k,x,y,m,n,sum = 0;
printf("Enter the first matrix row and column : ");
scanf("%d %d",&x,&y);
printf("Enter the second matrix row and column : ");
scanf("%d %d",&m,&n);
int anik[x][y],rob[m][n],ar[x][n];
printf("\nEnter the first matrix element : \n");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
printf("anik[%d][%d] = ",i,j);
scanf("%d",&anik[i][j]);
}
}
printf("\nEnter the second matrix element : \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("rob[%d][%d] = ",i,j);
scanf("%d",&rob[i][j]);
}
}
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<y;k++)
{
sum = sum + anik[i][k] * rob[k][j];
}
ar[i][j] = sum;
sum = 0;
}
}
printf("\nMultiple matrix : \n");
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",ar[i][j]);
}
printf("\n");
}
return 0;
}
int main()
{
int i,j,k,x,y,m,n,sum = 0;
printf("Enter the first matrix row and column : ");
scanf("%d %d",&x,&y);
printf("Enter the second matrix row and column : ");
scanf("%d %d",&m,&n);
int anik[x][y],rob[m][n],ar[x][n];
printf("\nEnter the first matrix element : \n");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
printf("anik[%d][%d] = ",i,j);
scanf("%d",&anik[i][j]);
}
}
printf("\nEnter the second matrix element : \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("rob[%d][%d] = ",i,j);
scanf("%d",&rob[i][j]);
}
}
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<y;k++)
{
sum = sum + anik[i][k] * rob[k][j];
}
ar[i][j] = sum;
sum = 0;
}
}
printf("\nMultiple matrix : \n");
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",ar[i][j]);
}
printf("\n");
}
return 0;
}
Comments
Post a Comment