title: How to transpose an array but without changing the number of rows and columns in c?
body: <p>I have recently encountered a problem in 2d array for which I am not able to get right solution.
  There's an array like:</p>
  <pre><code>    1,4,7,10,
      2,5,8,11,
      3,6,9,12
  </code></pre>
  <p>And I want it to be like:</p>
  <pre><code>    1,2,3,4,
      5,6,7,8,
      9,10,11,12
  </code></pre>
  <p>Heres a code snippet that I have written:</p>
  <pre><code>#include &lt;stdio.h&gt;    
  int main ()    
  {    
      
      int arr[3][4]={
          {1,4,7,10},
          {2,5,8,11},
          {3,6,9,12}
      };     
      
      int i,j;
      
      for(i=0;i&lt;3;i++)
      {
          for(j=0;j&lt;4;j++)
          {
              printf(&quot;%d &quot;,arr[i][j]);
          }
          printf(&quot;\n&quot;);
      }
      
      printf(&quot;\n\n&quot;);
      int copy[3][4];
      int temp[3][4];
      
      for(i=0;i&lt;3;i++)
      {
          for(j=0;j&lt;4;j++)
          {
             copy[][]
          }
          
      }
      
      for(i=0;i&lt;3;i++)
      {
          for(j=0;j&lt;4;j++)
          {
              printf(&quot;%d &quot;,copy[i][j]);
          }
          printf(&quot;\n&quot;);
      }
      return 0;
  }    
  </code></pre>