MULTIPLICATION OF TWO MATRIX with C programming
#include<stdio.h>
int main()
{
int i,j,k,ar,ac,br,bc,A[10][10],B[10][10],C[10][10];
imput:
printf("please ENTER ROW AND COLUMB OF YOUR FIRST MATRIX\n");
scanf("%d%d",&ar,&ac);
printf("please ENTER ROW AND COLUMB OF YOUR SECOND MATRIX\n");
scanf("%d%d",&br,&bc);
if(ac!=br){
printf(" *WORNING: YOUR 1ST MATRIX ROW SECOND MATRX COLUMB MUST BE SAME give imput agin*\n \n");
goto imput;
}
printf("please ENTER YOUR FRIST MATRIX %d values\n",ar*ac);
for(i=0;i<ar;i++){
for(j=0;j<ac;j++){
scanf("%d",&A[i][j]);
}
}
printf("please ENTER YOUR SECOND MATRIX %d values\n",br*bc);
for(i=0;i<br;i++){
for(j=0;j<bc;j++){
scanf("%d",&B[i][j]);
}
}
for(i=0;i<ar;i++){
for(j=0;j<bc;j++){
C[i][j]=0;
for(k=0;k<ar;k++){
C[i][j]=C[i][j]+A[i][k]*B[k][j];
}
}
}
printf("\n \nmutification of A*B matrix is:\n");
for(i=0;i<ar;i++){
for(j=0;j<bc;j++){
printf("\t%d ",A[i][j]);
}
printf("\n");
}
printf("*\n");
for(i=0;i<ar;i++){
for(j=0;j<bc;j++){
printf("\t%d ",A[i][j]);
}
printf("\n");
}
printf("=\n");
for(i=0;i<ar;i++){
for(j=0;j<bc;j++){
printf("\t%d ",C[i][j]);
}
printf("\n");
}
return 0;
}
trance-pose of matrix
#include<stdio.h>
int main()
{
int a[3][3],i,j;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
scanf("%d",&a[i][j]);
}
}
for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d",a[j][i]);
}
printf("\n");
}
return 0;
}
CEO & FOUNDER azomTech
No comments