title: Printing a Pattern with While loops and only using three output statements in C
body: <p>I have an assignment for school that is really got the best of me.</p>
  
  <p>Here is the question:</p>
  
  <blockquote>
    <p>(2) Write a C program using while
    loop(s) in combination with only the
    following three output statements
    (Each one appearing ONLY ONCE in your
    program): printf("* ");  printf("\n");
    printf(“^“); to print  the pattern:</p>
  
  <pre><code>* * * * * * * * ^
  * * * * * * * *
  * * * * * * * * ^
  * * * * * * * *
  * * * * * * * * ^
  * * * * * * * *
  </code></pre>
    
    <p>Note: there is a space between each *
    and the first, third, and fifth lines
    have a space before the  ^.</p>
  </blockquote>
  
  <p>And here is my code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main () {
  
   int star = 0;
   int row = 1;
   int hat = 1;
  
   while(row &lt; 6) {
  
    printf(" *");
    star++; 
  
    while(star &gt; 8) {
  
     while( (hat % 2) == 1) {
  
      printf(" ^"); 
     }
  
     printf("\n");
     row++;
    }
   }
      return 0; 
  }
  </code></pre>
  
  <p>I've tried many different versions of this code, and most of them ended up with infinitely printing rows of *.</p>
  
  <p>If anyone could help it would be great as I've tried and tried at this for a while now and even though I wish I could keep trying deadlines are deadlines and they always seem to come too fast.</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Rev.2 of the code:</p>
  
  <pre><code>include&lt;stdio.h&gt;
  
  int main () {
  int star = 0;
  int row = 1;
  int hat = 0;
  
  while(row &lt;= 6) {
  
      printf(" *");
      star++; 
  
      while(star &gt;= 8) {
          hat++;  
  
          if( (hat % 2) == 1) {
              printf(" ^");
              hat++;  
          }
  
          printf("\n");
          row++;
          star = 0;
      }
  }
  return 0;   
  }
  </code></pre>
  
  <p>Hopefully I am terminating the loops correctly but It seems not to be working.
  I'm not asking for a "get out of jail free" card but any are welcomed.</p>