/*****************************************************************/ // File : mattrans.c // Purpose : Compute the Transpose of a given matrix and display the result. // Author : Nanda Kishor K N // Mail Id : knnkishor@yahoo.com, nandakishorkn@rediffmail.com // Website : www.c4swimmers.esmartguy.com ( WEB MASTER ) // Group : c4swimmers@yahoogroups.com ( GROUP OWNER ) /*****************************************************************/ #include /* Name : main() Purpose : This is the main function that accepts the elements for a matrix and compute the transpose of the same matrix. Then display the result. This does not call any other function. Parameter : None */ int main() { // Variable Declarations & Initialization // Naming conventions are used like all integer variables should begin with 'i' int iRow,iCol,iIdx,jIdx,iMat[10][10]; printf("Enter row & column : "); scanf("%d,%d",&iRow,&iCol); // Accept the elements for a matrix. printf("\nEnter %d elements for matrix A\n",iRow * iCol); for (iIdx = 1; iIdx <= iRow; iIdx++) { for (jIdx = 1; jIdx <= iCol; jIdx++) scanf("%d",&iMat[iIdx][jIdx]); } // Display the result printf("\nTranspose of a matrix A is as follows\n"); for (iIdx = 1; iIdx <= iRow; iIdx++) { for (jIdx = 1; jIdx <= iCol; jIdx++) printf("%d\t",iMat[jIdx][iIdx]); printf("\n"); } return 0; } // End of Program