Write a c program to find transpose of matrix
Program:
#include<stdio.h> #include<conio.h> void main() { int a[2][2],i,j,m,n; printf("number of rows\n"); scanf("%d",&m); printf("number of columns\n"); scanf("%d",&n); printf("Enter element of matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } printf("Matrix is \n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",a[i][j]); } printf("\n"); } printf("Transpose of matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",a[j][i]); } printf("\n"); } }
Output:
number of rows 2 number of columns 3 2 Enter element of matrix 1 2 4 5 Matrix is 1 2 4 5 Transpose of matrix 1 4 2 5
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Program:
Output:
number of rows 2 number of columns 3 2 Enter element of matrix 1 2 4 5 Matrix is 1 2 4 5 Transpose of matrix 1 4 2 5
need an explanation for this answer? contact us directly to get an explanation for this answer