Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 781 Bytes

transposeMatrix.md

File metadata and controls

40 lines (31 loc) · 781 Bytes

Code:

#include <stdio.h>

void main()
{

    int a[10][10],i=0,j=0,t[10][10],r,c;
    printf("Enter row & column size:");
    scanf("%d%d",&r,&c);
 
    printf("Enter the matrix elements:");
    for(i=0;i<r;i++){ // Loop For Row 
        for(j=0;j<c;j++){ // Loop For Column
            scanf("%d",&a[i][j]); // Reads the Matrix
        }
    }
    
    // Transposing the Matrices
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            t[j][i]=a[i][j]; //Swapping Indexes
        }
    }

    printf("Transpose is:\n");
    for(i=0;i<c;i++){
        for(j=0;j<r;j++){
           printf("%d\t",t[i][j]); // Prints the resultant transpose
        }
        printf("\n"); // This will helps to print the elements row-wise
    }
}

Algorithm:

Will be updated