transpose of matrix in C Program

//transpose of matrix
//transpose of matrix
#include<stdio.h>
#include<conio.h>
#define ROWS 3
#define COLS 3
int main(void)
{
int a[ROWS][COLS]={{1,2,3},{4,5,6},{7,8,9}};
int i,j,tmp;
for(i=1;i<ROWS;i++)
{
for (j=0;j<COLS;j++)
{
tmp=a[i][j];
a[i][j]=a[j][i];
a[j][i]=tmp;

}

}
printf("TRANSPOSE of Matrix\n");
for(i=0;i<ROWS;i++)
{
for(j=0;j<COLS;j++)
printf("%d",a[i][j]);
printf("\n");

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image