0% found this document useful (0 votes)
12 views2 pages

Transpose A Matrix

Transpose of a matrix

Uploaded by

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

Transpose A Matrix

Transpose of a matrix

Uploaded by

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

TRANSPOSE OF A MATRIX

EXAMPLE PROGRAM 1
#include <stdio.h>
int main()
{
int m, n, i, j, a[10][10], transpose[10][10];
printf("Enter the number of rows and columns of a matrix\n");
scanf("%d%d", &m, &n);
printf("Enter elements of the matrix\n");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{ OUTPUT :
scanf("%d", &a[i][j]); Enter the number of rows and
} columns of a matrix
}
for (i = 0; i < m; i++) 3
{ 3
for (j = 0; j < n; j++) Enter elements of the matrix
{ 123
transpose[j][i] = a[i][j]; 456
} 789
Transpose of the matrix:
}
147
printf("Transpose of the matrix:\n"); 258
for (i = 0; i < n; i++) 369
{
for (j = 0; j < m; j++)
{
printf("%d\t", transpose[i][j]);
}
printf("\n");
}
return 0;
}
TRANSPOSE OF A MATRIX

EXAMPLE PROGRAM 2
#include <stdio.h>
int main()
{
int m, n,i,j, a[10][10];
printf("Enter the number of rows and columns of a matrix\n");
scanf("%d%d", &m, &n);
printf("Enter elements of the matrix\n");
for (i = 0; i < m; i++)
{ OUTPUT:
for (j = 0; j < n; j++) Enter the number of rows and columns of a matrix
{ 3
scanf("%d", &a[i][j]); 3
} Enter elements of the matrix
123
}
456
printf("The matrix is\n"); 789
for (i = 0; i < m; i++) The matrix is
{ 123
for (j = 0; j < n; j++) 456
789
{
Transpose of the matrix:
printf("%d\t", a[i][j]);
1 2 3
} 4 5 6
printf("\n"); 7 8 9
}
printf("\n Transpose of the matrix:\n");
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
return 0;
}

You might also like