title: Nested For Loops and outputting asterisks
body: <p>i have to write a c++ program that asks the user to enter an integer <em>k</em> and then outputs k lines of asterisks with the first line starting at 1 asterisk and the last line finishing with k asterisks.</p>
  
  <p>i can get the program to output a square of asterisks such as:
  (k=5)</p>
  
  <pre><code>*****
  *****
  *****
  *****
  *****
  </code></pre>
  
  <p>when it should look like this:</p>
  
  <pre><code>*
  **
  ***
  ****
  *****
  </code></pre>
  
  <p>how should i adjust my program to accomplish this?
  (Note: i have to use two for loops.)</p>
  
  <pre><code>int main() {
      int k, cols, rows;
      cout &lt;&lt; " Please enter a number: ";
      cin &gt;&gt; k;
  
      for (cols = 1; cols &lt; k + 1; cols++) {
          for (rows = 1; rows &lt; k + 1; rows++)
              cout &lt;&lt; "*";
          cout &lt;&lt; endl;
      }
  
      getchar();
      getchar();
      return 0;
  }
  </code></pre>