c-language.....

1. write a program transpose matrices.
ans:- #include <stdio.h>
         #include <conio.h>
          void main()
          {
           int mat[3][3], trans[3][3], row, col;
            clrscr();
          for(row=0;row<3;row++)
         {
          for(col=0;col<3;col++)
         {
        printf("input the data")
        scanf("%d", &mat[row] [col]);
   }
}
       for(row=0;row<3;row++)
       {
      for(col=0;col<3;col++)
       {
         trans[row][col]= mat[col][row];
    }
        for(row=0;row<3;row++)
        {
        for(col=0;col<3;col++)
        {
      printf("\t%d", trans[row][col]);
   }
     printf("\n");
  } 
     grtch();
                }

Comments