title: How to print the given ZIG ZAG pattern using C?
body: <p><a href="https://i.stack.imgur.com/qzlpw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qzlpw.png" alt="Zig Zag Pattern"></a></p>
  
  <p>I'm scratching my head from the morning and I didn't even reach something which looks like given pattern. Any amount of help is appreciated. 
  Thanks in advance!</p>
  
  <p><strong>This is not my home work</strong></p>
  
  <p>EDIT 1: Thank You all! I finally arrived at the solution.</p>
  
  <pre><code>`#include&lt;stdio.h&gt;
  
    void main(){
       int n,i,count;
       scanf("%d",&amp;n);
       int prev=n,next=(n*2)+(n-2),tc=1;
       for(int i=1;i&lt;=n;i++){
              if(i==1) {
                  for(count=1;count&lt;=(n*2)+(n-2);count++)  {
                      if(count==prev || count==next) printf("*");
                      else printf(" ");  
                  }
              }
              else  {
                  for(count=1;count&lt;=2*n*n;count++){
                      if(count==prev-tc || count==prev+tc ||   count==next-tc|| count==next+tc) 
                             printf("*");
                      else printf(" ");
                  }
             tc++;
            }
       printf("\n");
       }
    }`
  </code></pre>