C Program to find the Transpose of a Matrix.
In this example, we will find the transpose of a given matrix according to the requirements of the row size and column size.
Here in the output we have entered a 3x2 Matrix whose transpose will be 2x3 Matrix.
PROGRAM
#include<stdio.h>
#include<conio.h>
int main()
{
int row,column,i,j,a[100][100];
printf("Enter the row size of the matrix :");
scanf("%d",&row);
printf("Enter the column size of the matrix : ");
scanf("%d",&column);
printf("Enter the elements of the matrix : ");
for(i=0;i<row;i++)
{
for(j=0;j<column;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("The transpose of the MAtrix is : \n");
for(j=0;j<column;j++)
{
for(i=0;i<row;i++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}
OUTPUT
Enter the row size of the matrix :3
Enter the column size of the matrix : 2
Enter the elements of the matrix : 1
2
3
4
5
6
The transpose of the MAtrix is :
1 3 5
2 4 6
NOTE: You Can Comment Your Code if you have solved differently and we will pin it in the comment section. Let's Learn together.
MOTTO:
You Learn, I Learn together We Learn.
Comments
Post a Comment
Please do not spam any link