title: Printing out characters in a target table pattern
body: <p>I have to do a code in c, which is printing out <strong>target table</strong> pattern. </p>
  
  <pre><code>So input for example:
  
  3
  1
  2
  3
  
  
  and the output:
  
  *
  
  *****
  *   *
  * * *
  *   *
  *****
  
  *********
  *       *
  * ***** *
  * *   * *
  * * * * *
  * *   * *
  * ***** *
  *       *
  *********
  </code></pre>
  
  <p>I have done several tries, but its not working, cant do the mid-zones.<br>
  I've done this code, and for 1-2 its working, but i cant do for 2+.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;math.h&gt;
  
  int main()
  {
      int n,i,k;
      int p=0;
      int j=0,l=0;
      int d=0;
      scanf("%d",&amp;n);
      for(i=0; i&lt;n; i++)
      {
          scanf("%d",&amp;k);
          d=((4*k)-3)*((4*k)-3);
              p=((4*k)-3);
          for(j=0; j&lt;p; j++)
          {
              if(j==0 || j==p-1)
              {
                  for(l=0; l&lt;p; l++)
                      printf("*");
                          printf("\n");
              }
  
              if(j==p/2+1)
              {
                      for(l=0; l&lt;p; l++)
                          {
                          if(l%2==0) 
                              printf("*");
                          else printf(" ");
                          }
                      printf("\n");
              }
              if(j&gt;0 &amp;&amp; j&lt;p/2)
              {
                      for(l=0; l&lt;p; l++)
                      {   
                          if(l==0 || l==p-1)
                              printf("*");
                          else printf(" ");
                      }
                      printf("\n");
                          }
                          if(j&gt;p/2 &amp;&amp; j&lt;p-1)
              {
                      for(l=0; l&lt;p; l++)
                      {   
                          if(l==0 || l==p-1)
                              printf("*");
                          else printf(" ");
                      }
                      printf("\n");
                          }
  
          }
      }
      return 0;
  }
  </code></pre>