/* Matrix multiplication and Transpose - Program to perform matrix multiplication and transpose - May 2013 */ #include #include void read(int x[ ][10], int nr, int nc) ; void multiply(int a[ ][10], int b[ ][10], int c[ ][10], int l, int m, int n) ; void transpose(int x[ ][10], int y[ ][10], int nr, int nc) ; void show(int y[ ][10], int nr, int nc) ; void main() { int a[10][10], b[10][10], c[10][10], nra, nca, nrb, ncb ; int x[10][10], y[10][10], m, n ; clrscr(); printf("Performing Matrix Multiplication \n \n") ; printf("Enter the number of rows and columns of first matrix: ") ; scanf("%d %d", &nra, &nca) ; printf("Enter the number of rows and columns of second matrix: ") ; scanf("%d %d", &nrb, &ncb) ; if(nca==nrb) { printf("Enter elements of first matrix row-wise: \n") ; read(a,nra,nca) ; printf("Enter elements of second matrix row-wise: \n") ; read(b,nrb,ncb) ; multiply(a,b,c,nra,nca,ncb); printf("Result of matrix multiplication is: \n") ; show(c,nra,ncb) ; } else printf("Matrices A and B do not conform to multiplication") ; printf("\nPerforming Matrix transpose \n \n") ; printf("Enter the number of rows and columns: ") ; scanf("%d %d", &m, &n) ; printf("Enter elements of the matrix row-wise:\n") ; read(x, m, n) ; transpose(x, y, m, n) ; printf("Transpose of given matrix is:\n") ; show(y,n,m) ; getch() ; } void read(int x[ ][10], int nr, int nc) { int r, c ; for(r=0 ; r