C Program to Find Transpose of a Matrix
#include<stdio.h> #include<conio.h> void main() { int a[10][10], t[10][10], k,n,i,j; clrscr(); printf("How many rows and columns you want to give ?"); scanf("%d%d",&k,&n); printf("Enter the value of A matrix :"); for(i=0;i<k;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); for(i=0;i<k;i++) for(j=0;j<n;j++) t[j][i]=a[i][j]; printf("The transposed matrix is :"); for(i=0;i<n;i++) { for(j=0;j<k;j++) printf("%5d",t[i][j]); printf("\n"); } getch(); }
Output: