-->
Showing posts with label transpose of matrix. Show all posts
Showing posts with label transpose of matrix. Show all posts

Thursday, May 29, 2025

c program to print transpose of matrix of order 3x2 | 2D Array-matrix examples

 Array programs collections

/* program to find transpose of given matrix of order 3x2

*/

#include<stdio.h>

int main()

{

int matrix[3][2];

int i,j;

for(i=0;i<=2;i++)

{

for(j=0;j<=1;j++)

{

printf("data for %d %d location is:",i,j);

scanf("%d",&matrix[i][j]);

}

}

printf("the matrix before transpose is:\n");

for(i=0;i<=2;i++)

{

for(j=0;j<=1;j++)

{

printf("%d",matrix[i][j]);

}

printf("\n");

}

printf("the matrix after transpose is:\n");

for(i=0;i<=1;i++)

{

for(j=0;j<=2;j++)

{

printf("%d",matrix[j][i]);

}

printf("\n");

}

return 0;

}


Output:

c program to transpose a matrix