Q.no Program to calculate the multiple of the two matrix in c-language
In this program, we will calculate the product of the two matrices (two -dimensional arrays).
user print the values of the two matrices of order 3x3. i.e
Multiple of two matrices, the number of columns of the first matrix should be equal to the number of the second matrix.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k;
printf("enter the values of the first matrices");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("enter the values of the second matrices");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
printf("the multiple of the matrices is \n");
for(i=0;i<3;i++){
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++){
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
printf("%d ",c[i][j]);
}
printf("\n");
}
getch();
}
output are follow:-

No comments:
Post a Comment