Thursday, February 4, 2010

How to multiply two matrices in c Programming

#include
void main(int *argv,char argc*[])
{
int *mat1[10],*mat2[10],*mat3[10];
int i,j,m,n;
printf("Enter the value row and column:-");
scanf("%d%d",&m,&n);
for(i=0;i{
mat1[i]=(int*)calloc(m,sizeof(int));
mat2[i]=(int*)calloc(m,sizeof(int));
mat3[i]=(int*)calloc(m,sizeof(int));
}
printf("Enter the value of Matrix1:-\n");
for(i=0;i{
for(j=0;jscanf("%d",(*(mat1+i)+j));
}
printf("Enter the value of Matrix2:-\n");
for(i=0;i{for(j=0;jscanf("%d",(*(mat2+i)+j));
}for(i=0;i{for(j=0;j{
*(*(mat3+i)+j)=*(*(mat1+i)+j) * *(*(mat2+i)+j);
}
}
printf("The Product Of Above Two Matrix:-\n");


for(i=0;i{for(j=0;j{printf("%d",*(*(mat3+i)+j));
}
printf("\n");
}
}

No comments:

Post a Comment