title: Swap Function is not swapping elements of 2D array in c++
body: <p>So this transpose function is supposed to swap elements of 2d array but it is not swapping it.</p>
  
  <p>Output of program is same as its input.</p>
  
  <pre><code>input:
        1 2 3 4 5 6 7 8 9
  output:
        123456789
  </code></pre>
  
  <p>I even tried replacing swap function with my swapping code in which you use temp variable to swap two elements which is also not working, so i have no idea what is going on.</p>
  
  <pre><code>void transpose(int input_arr[][3], int n) {
          for (int i = 0; i &lt; n; i++) {
              for (int j = 0; j &lt; n; j++) {
                  swap(input_arr[i][j], input_arr[j][i]);
              }
          }
          for (int i = 0; i &lt; n; i++) {
              for (int j = 0; j &lt; n; j++) {
                  cout &lt;&lt; input_arr[i][j];
              }
          }
      }
  
      int main()
      {
          const int n = 3;
          int row = 3;
          int col = 3;
          int input_arr[n][n];
  
          arr(input_arr, n);
          transpose(input_arr, n);
      }
  </code></pre>