Uploaded by aryaj0705

multiplication of matrix

advertisement
#include<stdio.h>
int main()
{
int m,n,i,j,k,x,y;
int a[100][100],b[100][100],c[100][100];
clrscr();
printf("Enter Number of Rows and Columns in Matrix a:");
scanf("%d%d", &m, &n);
printf("Enter Number of Rows and Columns in Matrix b:");
scanf("%d%d", &x, &y);
if(n!=x)
{
printf("Multiplication is not possible");
}
else
{
printf("Enter Matrix a");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("Enter a[%d][%d] :", i,j);
scanf("%d\n",&a[i][j]);
}
}
printf("Enter Matrix b");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
printf("Enter a[%d][%d] :", i,j);
scanf("%d\n",&b[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<y;j++)
{
c[i][j]=0;
}
for(k=0;k<n;k++)
{
c[i][j] += a[i][j]+b[i][j];
}
}
printf("The multiplication of Matrix a and b is");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d", c[i][j]);
}
printf("\n");
}
}
return 0;
}
Download