Write a c program to find transpose of a matrix
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],i,j,r,c;
clrscr();
printf("Enter the order of matrix:\n");
scanf("%d%d",&r,&c);
printf("Enter the elements\n");
for(i=0;i<r;i++)
for(j=0;j<c;j++)
scanf("%d",&a[i][j]);
printf("Entered matrix is\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
printf("%d",a[i][j]);
printf("\n");
}
printf("Transpose of a matrix\n");
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
printf("%d",a[j][i]);
printf("\n");
}
getch();
}
Output:
Enter the order of matrix:
2
3
Enter the elements
1
2
3
4
5
6
Entered matrix is
123
456
Transpose of a matrix
14
25
36
No comments: