Program to transpose the given matrix
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int mat[10][10];
int i, j, row, col;
clrscr();
printf("Enter the order of the matrix : ");
scanf("%d %d", &row, &col);
printf("\nEnter the elements of the matrix : \n\n");
for(i = 0; i < row; i++)
for(j = 0; j < col; j++)
scanf("%d", &mat[i][j]);
printf("\nThe transpose matrix is : \n\n");
for(i = 0; i < col; i++)
{
for(j = 0; j < row; j++)
{
printf("%d \t", mat[j][i]);
}
printf("\n");
}
getch();
}
Output:
Enter the order of the matrix : 2 3
Enter the elements of the matrix :
1 2 3
4 5 6
The transpose matrix is :
1 4
2 5
3 6
-
UpdatedDec 31, 2019
-
Views5,413
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order