C program to transpose the matrix
#include <stdio.h<
int main()
{
int a[10][10], i, j, row, col, trans[10][10];
printf("Enter no. of rows:");
scanf("%d", &row);
printf("Enter no. of columns:");
scanf("%d", &col);
printf("Enter elements of matrix:");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
scanf("%d", &a[i][j]);
}
}
printf("\nThe given matrix is :\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
printf("\nThe matrix after transpose is :\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
trans[i][j] = a[j][i];
printf("%d\t", trans[i][j]);
}
printf("\n");
}
}
Post A Comment:
0 comments so far,add yours