#include<iostream.h>
#include<conio.h>
int main()
{
int arr1[20][20],arr2[20][20],result[20][20];
int m,n,i,j;
printf("enter the no. of rows");
scanf("%d",&m);
printf("enter the no. of columns");
scanf("%d",&n);
printf("enter the elements of first matrix \n");
for( i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&arr1[i][j]);
}
}
printf("elements of second matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&arr2[i][j]);
}
}
printf("\n resultant matrix \n");
int k=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
result[i][j]=0;
for(k=0;k<m;k++)
{
result[i][j]=result[i][j]+arr1[i][k]*arr2[k][j];
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\n\t",result[i][j]);
}
printf("\n\n");
}
getch();
}Friday, September 23, 2016
C program for matrix multiplication
Labels:
array,
C,
Matrix multiplication
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment