title: Printing out characters in an X pattern using for loops
body: <p>I'm trying to print this big X pattern:</p>
  
  <pre><code> x       x
    x     x
     x   x
      x x
       x
      x x
     x   x
    x     x
   x       x
  </code></pre>
  
  <p>I can't figure out the algorithm to make it. I'm just starting C programming and getting stuck.</p>
  
  <p>What I have so far is </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      int j,i;
      char ch[] = "$";
      for(int j = 5; j &gt;= 0 ; --j)
      {
          for(i = 5; i&gt;=0; --i)
          {
              if(j%2 == 1)
              {
                   printf("%s",ch);
              }
  
          }
      printf("\n");
      }
      return 0;
  }
  </code></pre>
  
  <p>I figured out the pattern too,</p>
  
  <pre><code>0  5  0
  1  3  1 
  2  1  2
  3  0  3
  2  1  2
  1  3  1
  0  5  0 
  </code></pre>
  
  <p>The numbers on the edge are where a * should appear. The numbers in the middle are where spaces should appear. What am I missing?</p>