title: Program to code zigzag matrix vertically
body: <p>I am writing a dynamic code that print n x n matrix in a zigzag pattern. Please help me with the code to get the output stated below:     </p>
  
  <p>The Code that I've tried so far with help of Rizier123 is in horizontal zigzag pattern:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
  
      int rows, columns;
      int rowCount, columnCount, count = 0;
  
      printf("Please enter rows and columns:\n&gt;");
      scanf("%d %d", &amp;rows, &amp;columns);
  
  
      for(rowCount = 0; rowCount &lt; rows; rowCount++) {
  
          for(columnCount = 1; columnCount &lt;= columns; columnCount++) {
  
              if(count % 2 == 0)
                  printf("%4d " , (columnCount+(rowCount*columns)));
              else
                  printf("%4d " , ((rowCount+1)*columns)-columnCount+1);
  
          }
          count++;
          printf("\n");
      }
  
  
      return 0;
  
  }
  </code></pre>
  
  <p>Input:</p>
  
  <pre><code>5 5
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code> 1  2  3  4  5
  10  9  8  7  6
  11 12 13 14 15
  20 19 18 17 16
  21 22 23 24 25 
  </code></pre>
  
  <p>I want the same zigzag pattern output but vertically..</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Expected output:</p>
  
  <pre><code>1 10 11 20 21 30
  2  9 12 19 22 29
  3  8 13 18 23 28
  4  7 14 17 24 27
  5  6 15 16 25 26
  </code></pre>