0% found this document useful (0 votes)
34 views1 page

Multiplication of Matrix NN

The document contains a C program that performs matrix multiplication. It prompts the user to enter the dimensions and elements of two matrices, multiplies them, and then prints the resulting matrix. The program uses nested loops to compute the product of the matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Multiplication of Matrix NN

The document contains a C program that performs matrix multiplication. It prompts the user to enter the dimensions and elements of two matrices, multiplies them, and then prints the resulting matrix. The program uses nested loops to compute the product of the matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include<stdio.

h>
int main(){
int m,n;
printf("Enter a size of matrix first = ");
scanf("%d%d",&m,&n);
int m1[m][n];
printf("Enter element = ");
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
scanf("%d",&m1[i][j]);
}
}

int m2[m][n];
printf("Enter element = ");
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
scanf("%d",&m2[i][j]);
}
}
int m3[m][n];
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
m3[i][j]=0;
for(int k=0; k<m; k++){
m3[i][j]=m3[i][j]+(m1[i][k]*m2[k][j]);
}
}
}

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


for(int j=0; j<n; j++){
printf("%d ",m3[i][j]);

}
printf("\n");
}
}

You might also like