C Program to display the transpose of a given matrix.



#include<stdio.h>
#include<conio.h>
void main()
{
   int m[20][20],i,j,x,y;
   clrscr();
   printf("\nEnter the order of matrix : ");
   scanf("%d%d",&x,&y);
   printf("\nEnter the elements\n");
   for(i=0;i<x;i++)
      for(j=0;j<y;j++)
         scanf("%d",&m[i][j]);
   printf("The Transpose it:\n\n\t");
   for(i=0;i<y;i++)
   {
      for(j=0;j<x;j++)
         printf(" %d",m[j][i]);
      printf("\n\t");
   }
   getch();
}

algorithm

step1:start
step2:read x,y
step3:intilize i<-0
step 4:check whether i<x,thengo to step5
   else go to step12
step 5:intilize j<-0
step 6:check whether j<y,then go to step7
   else go to step10
step7:read m[i][j]
step8:j=j+1
step9:go to step6
step10:i=i+1
step11:go to step4
step12:intilize i<-0
step13:check whether i<y,thengo to step14
   else go to step21
step14ntilize j<-0
step15check whether j<x,then go to step16
   else go to step19
step16:print m[i][j]
step17:j=j+1
step18:go to step15
step19:i=i+1
step20:go to step13
step 21:stop