matrix transpose, can any plz check this program.

No replies
karthikjs
Offline
Last seen: 7 years 10 weeks ago
Joined: 2011-04-06
bOt Points: 54

/*WAP to transpose of given matrix*/

#include<stdio.h>
#include<conio.h>
void main()
{
int mat[20][20]; int tmat[20][20];
int i,j,r,c;
printf("Enter the row and column size\n");
scanf("%d%d",&r,&c);
printf("Enter the array elements for %d*%d matrix\n",r,c);
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
printf("mat[%d][%d]=",i,j);
scanf("%d",mat[i][j]);
tmat[i][j]=mat[j][i] ;
}
printf("\n");
}
clrscr();

printf("Transpose of matrix is\n");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
printf("%d\t", tmat[i][j]);
}
printf("\n");
}
getch();
}