Mega Code Archive
Transpose of a matrix
#include
#include
#define ROW 3
#define COL 3
void dis(int a[][COL],int,int);
void trans(int a[][COL],int,int);
void main()
{
int a[ROW][COL];
a[0][0] = 1; a[0][1] = 2; a[0][2] = 3;
a[1][0] = 4; a[1][1] = 5; a[1][2] = 6;
a[2][0] = 7; a[2][1] = 8; a[2][2] = 9;
printf("\nThe matrix is \n");
dis(a,ROW,COL);
trans(a,ROW,COL);
printf("The tranpose of the matrix is\n");
dis(a,ROW,COL);
getch();
}
void dis(int d[3][3 ],int i,int k)
{
int j,l;
for(j=0;j