#include<stdio.h> #include<conio.h> void main() { int a[10][10],m,i,j,temp; /* actual size of matrix is m*n i,j - for scanning of array temp - for interchanging of a[i][j] and a[j][i] */ printf("n Enter the size of matrix :"); scanf("%d",&m); /* Reading elements of matrix */ printf("n Enter the values a:"); for(i=0;i<m;i++) for(j=0;j<m;j++) scanf("%d",&a[i][j]); //to print original square matrix printf("nGiven square matrix is"); for(i=0;i<m;i++) { printf("n"); for(j=0 ; j 〈 m ; j++) printf("%dt",a[i][j]); } /* Find transpose */ for(i=1;i<m;i++) for(j=0;j<i;j++) { temp=a[i][j]; a[i][j]=a[j][i]; a[j][i]=temp; } /* printing of all elements of final matrix */ printf("nTranspose matrix is :"); for(i=0;i 〈 m;i++) { printf("n"); for(j=0;j<m;j++) printf("%dt",a[i][j]); } getch(); }
Next
« Prev Post
« Prev Post
Previous
Next Post »
Next Post »
Subscribe to:
Post Comments (Atom)