0% found this document useful (0 votes)
68 views1 page

12 To Transpose A Matrix

This C program takes a matrix as input from the user along with its number of rows and columns. It then transposes the matrix by swapping the rows and columns and stores it in a new matrix. Finally, it prints out the transposed matrix.

Uploaded by

amishadalal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views1 page

12 To Transpose A Matrix

This C program takes a matrix as input from the user along with its number of rows and columns. It then transposes the matrix by swapping the rows and columns and stores it in a new matrix. Finally, it prints out the transposed matrix.

Uploaded by

amishadalal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>

C program to transpose a int main()


{
matrix int m, n, c, d, matrix[10][10], transpose[10]
[10];

This c program prints transpose of a matrix. It is obtained by printf("Enter the number of rows and columns of
interchanging rows and columns of a matrix. For example if a matrix\n");
matrix is scanf("%d%d", &m, &n);
12 printf("Enter the elements of matrix\n");
34
56 for (c = 0; c < m; c++)
for(d = 0; d < n; d++)
then transpose of above matrix will be
scanf("%d",&matrix[c][d]);
135
246 for (c = 0; c < m; c++)
for( d = 0 ; d < n ; d++ )
When we transpose a matrix then the order of matrix changes,
transpose[d][c] = matrix[c][d];
but for a square matrix order remains same.
printf("Transpose of entered matrix :-\n");

for (c = 0; c < n; c++) {


for (d = 0; d < m; d++)
printf("%d\t",transpose[c][d]);
printf("\n");
}

return 0;
}

You might also like