Advertisement
ZinedinZidan

transe

Oct 29th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int a[10][10],transpose[10][10],i,j,row,col;
  5.     printf("Enter a number of rows and cols for the matrix : ");
  6.     scanf("%d %d",&row,&col);
  7.  
  8.     for(i=0; i<row; i++)
  9.     {
  10.         for(j=0; j<col; j++)
  11.         {
  12.             printf("a[%d][%d]= ",i,j);
  13.             scanf("%d",&a[i][j]);
  14.         }
  15.     }
  16.  
  17.     for(i=0; i<row; i++)
  18.     {
  19.         for(j=0; j<col; j++)
  20.         {
  21.             transpose[j][i]=a[i][j];
  22.  
  23.         }
  24.     }
  25.  
  26.     //printing the matrix
  27.     printf("\nEntered Matrix = \n");
  28.     for(i=0; i<row; i++)
  29.     {
  30.         printf("\t\t");
  31.         for(j=0; j<col; j++)
  32.         {
  33.             printf("%d ",a[i][j]);
  34.         }
  35.         printf("\n");
  36.     }
  37.  
  38.     //Transpose the matrix
  39.     printf("\nTranspose Matrix = \n");
  40.     for(i=0; i<col; i++)
  41.     {
  42.         printf("\t\t");
  43.         for(j=0; j<row; j++)
  44.         {
  45.             printf("%d ",transpose[i][j]);
  46.         }
  47.         printf("\n");
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement