#include<stdio.h>
int multiply(int x[20][20],int y[20][20],int ,int ,int );
int main()
{
int x[20][20],y[20][20];
int i,j,k,m,n,p;
printf("Enter the number of rows and columns for the 1st matrix :- \n");
scanf("%d%d",&m,&n);
printf("Enter the elements of the 1st matrix :- \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&x[i][j]);
}
}
printf("Enter the number of columns for 2nd matrix\n");
scanf("%d",&p);
printf("Enter the elements of the 2nd matrix\n");
for(i=0; i<n; i++)
{
for(j=0; j<p; j++)
{
scanf("%d",&y[i][j]);
}
}
printf("The 1st matrix is :-\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",x[i][j]);
}
printf("\n");
}
printf("The 2nd matrix is :-\n");
for(i=0;i<n;i++)
{
for(j=0;j<p;j++)
{
printf("%d\t",y[i][j]);
}
printf("\n");
}
multiply(x,y,m,n,p);
}
int multiply(int x[20][20],int y[20][20],int m,int n,int p)
{
int mul[20][20],i,j,k;
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
mul[i][j]=0;
for(k=0;k<n;k++)
{
mul[i][j]=mul[i][j]+x[i][k]*y[k][j];
}
}
}
printf("The resultant matrix derived : \n");
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
printf("%d\t",mul[i][j]);
}
printf("\n");
}
}
int multiply(int x[20][20],int y[20][20],int ,int ,int );
int main()
{
int x[20][20],y[20][20];
int i,j,k,m,n,p;
printf("Enter the number of rows and columns for the 1st matrix :- \n");
scanf("%d%d",&m,&n);
printf("Enter the elements of the 1st matrix :- \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&x[i][j]);
}
}
printf("Enter the number of columns for 2nd matrix\n");
scanf("%d",&p);
printf("Enter the elements of the 2nd matrix\n");
for(i=0; i<n; i++)
{
for(j=0; j<p; j++)
{
scanf("%d",&y[i][j]);
}
}
printf("The 1st matrix is :-\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",x[i][j]);
}
printf("\n");
}
printf("The 2nd matrix is :-\n");
for(i=0;i<n;i++)
{
for(j=0;j<p;j++)
{
printf("%d\t",y[i][j]);
}
printf("\n");
}
multiply(x,y,m,n,p);
}
int multiply(int x[20][20],int y[20][20],int m,int n,int p)
{
int mul[20][20],i,j,k;
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
mul[i][j]=0;
for(k=0;k<n;k++)
{
mul[i][j]=mul[i][j]+x[i][k]*y[k][j];
}
}
}
printf("The resultant matrix derived : \n");
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
printf("%d\t",mul[i][j]);
}
printf("\n");
}
}
OUTPUT : -
Follow
Me On Social Media :-
INSTA photography page :- https://www.instagram.com/photo_mania_hub/
Twitter link : - https://twitter.com/ApurbaKhanra199
Facebook page link (Crazy Coders) :-https://www.facebook.com/codercrazy/?modal=admin_todo_tour
Insta photography link :- https://www.instagram.com/photo_mania_hub/
Facebook link :- https://www.facebook.com/profile.php?id=100009747586288
For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/
0 Comments