C Program to find multiplication of two 2-Dimensional Array
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,p,q,i,j,z,sum,x[10][10],
y[10][10],k[10][10];
printf("Enter the row & column
of first array :\n");
scanf("%d%d",&m,&n);
printf("Enter the row & column
of second array :\n");
scanf("%d%d",&p,&q);
if(n!=p)
{
printf("\nMatrix multiplic
ation is not possible :");
}
else
{
printf("\nEnter the elements
in first array :\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&x[i][j]);
}
printf("\nEnter the elements
in second array :\n");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
scanf("%d",&y[i][j]);
}
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
{
sum=0;
for(z=0;z<n;z++)
sum=sum+x[i][z]
*y[z][j];
k[i][j]=sum;
}
}
printf("\nResult will be :
\n");
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
{
printf("%d\t",
k[i][j]);
}
printf("\n");
}
}
getch();
}
Output :-
0 Comments
Tell us your queries or more topics which you want