Thursday, July 30, 2009

multiplication of two matrices

//program for multiplication of two rectaangular matrices
#include
#include
void main()
{
int a[10][10],b[10][10],c[10][10],r,i,j,k,m,n;
clrscr();

printf("\nEnter the rows and columns of matrix :");
scanf("%d %d",&m,&n);
printf("\n enter the matrix a:");
for(i=0;i for(j=0;j scanf("%d",&a[i][j]);
printf("\nEnter the no of columns of matrix :");
scanf("%d",&r);
printf("\n enter the matrix b:");
for(i=0;i for(j=0;j scanf("%d",&b[i][j]);

printf("the multiplication of mtrices a and b is c:\n");
for(i=0;i {
for(j=0;j {
c[i][j]=0;
for(k=0;k c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
printf("%d ",c[i][j]);
}
printf("\n");
}
getch();
}

No comments:

Post a Comment