title: How to alter my program to use while loops instead of for loops. Asterisk triangle in c
body: <p>For my programming assignment I have to create 3 programs that print out an asterisk based triangle in c based on the user's input.  The difference between the 3 programs would be one will use for loops, the other would use while loops and the last one would use goto.  I have the for loop program as well as the goto program, but as for the while loop program I'm not sure how incorporate it into my program.  This is my program with a for loop and the second program is my attempt at the while loop version.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
  int lines, a, b;
  
  //prompt user to input integer
  do{
      printf("Input a value from 1 to 15: ");
      scanf("%d", &amp;lines);
  
  //Check if inputed value is valid
  if(lines &lt; 1 || lines &gt; 15) {
      printf("Error: Please Enter a Valid number!!!\n");
      continue;
  }
  /*create triangle based on inputed value */
      for(a = 1; a &lt;= lines; a++) {
          for(b=1; b&lt;= a; b++) {
              printf("*");
          }
          printf("\n");
      }
  }    while(1);
   system("pause");
  }
  </code></pre>
  
  <p>Progam #2:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
  int lines, a = 1, b = 1;
  
  //prompt user to input integer
  do{
      printf("Input a value from 1 to 15: ");
      scanf("%d", &amp;lines);
  
  //Check if inputed value is valid
  if(lines &lt; 1 || lines &gt; 15) {
      printf("Error: Please Enter a Valid number!!!\n");
      continue;
  }   
      while(a &lt;= lines) {
          a++;
          while (b &lt;= a) {
              b++;
              printf("*");
          }
          printf("\n");
      }    
  }    while(1);
  system("pause");
  }
  </code></pre>