Search This Blog

Friday, April 22, 2011

CODE 07

//GAURAV MITTAL(2K9/EE/830)
//QUESTION 7. Find the transpose and multiply two matrices.

#include
#include

int main()
{
int a[10][10],b[10][10],c[10][10],i,j,k,l,m,n;
printf("\n\n\n\n\n\n\nEnter the no.of rows for MATRIX A :");
scanf("%d",&l);
printf("\nEnter the no.of columns for MATRIX A :");
scanf("%d",&m);
for(i=0;i {
for(j=0;j {
printf("\nEnter element A[%d",i+1);
printf("][%d",j+1);
printf("] : ");
scanf("%d",&a[i][j]);
}
}

printf("\n\n\nEnter the no.of columns for MATRIX B :");
scanf("%d",&n);
for(i=0;i {
for(j=0;j {
printf("\nEnter element B[%d",i+1);
printf("][%d",j+1);
printf("] : ");
scanf("%d",&b[i][j]);
}
}

printf("\n\n\n\t\tMATRIX A :\n");
for(i=0;i {
printf("\n");
for(j=0;j {
printf("\t");
printf("%d",a[i][j]);
}
}

printf("\n\n\n\t\tMATRIX B :\n");
for(i=0;i {
printf("\n");
for(j=0;j {
printf("\t");
printf("%d",b[i][j]);
}
}

printf("\n\n\n\n\nThe transpose of MATRIX A is :\n");
for(j=0;j {
printf("\n");
for(i=0;i {
printf("\t");
printf("%d",a[i][j]);
}
}

printf("\n\n\nThe transpose of MATRIX B is :\n");
for(j=0;j {
printf("\n");
for(i=0;i {
printf("\t");
printf("%d",b[i][j]);
}
}

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("\n\n\n\n\nThe product of the two matrices is :\n");
for(i=0;i {
printf("\n");
for(j=0;j {
printf("\t");
printf("%d",c[i][j]);
}
}
getch();
return 0;
}

No comments:

Post a Comment