prev


Multi-dimensional Integer Arrays:

71.Product of matrix (12.05.2010)

/*
Program# 71
date : 28-12-2008
Product of Matrix
*/

#include <stdio.h>
main(){
int i=0,j=0,a[3][3],b[3][3],c[3][3];
int k=0;
while(i<3){
j=0;
while(j<3){
scanf("%d",&a[i][j]);
j=j+1;
}
i=i+1;
}

i=0;
while(i<3){
j=0;
while(j<3){
scanf("%d",&b[i][j]);
j=j+1;
}
i=i+1;
}
//display
i=0;
while(i<3){
j=0;
while(j<3){
k=0;
while(k<3){
c[i][j]=0;
c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
k++;
}
j=j+1;
}
i=i+1;
}

//display
i=0;
while(i<3){
j=0;
while(j<3){
printf("\t%d",c[i][j]);
j=j+1;
}
printf("\n");
i=i+1;
}

}



next
blog comments powered by Disqus