Computer Science, asked by roshu4646, 11 months ago

Write a program to find the sum of two matrix of size mxn and nxp

Answers

Answered by yashagarwal140
0

Answer:

#include<stdio.h>

#include<conio.h>

#define ROW 20

#define COL 20

void main()

{

int a[ROW][COL],b[ROW][COL],c[ROW][COL];

int i=0,j=0,k,sum=0,m,n;

clrscr();

printf("\n enter the m\n");

scanf("%d",&m);

printf("\n enter the n\n");

scanf("%d",&n);

printf("\n enter the matrix A elements ");

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

scanf("%d",&a[i][j]);

}

}

printf("\n the matrix A elements ");

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

printf("%d",a[i][j]);

}

printf("\n");

}

printf("\n enter the matrix B elements ");

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

scanf("%d",&b[i][j]);

}

}

printf("\n the matrix B elements ");

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

printf("%d",b[i][j]);

}

printf("\n");

}

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

sum=0;

for(k=0;k<n;k++)

sum=sum+a[i][k]*b[k][j];

c[i][j]=sum;

}

}

printf("\n the product of matrices is as follow \n");

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

printf("\t%d",c[i][j]);

}

printf("\n");

}

getch();

}

Read more on Brainly.in - https://brainly.in/question/6853029#readmore

Explanation:

Similar questions