title: Printing number of stars with equal spaces to create a V
body: <p>I am coding in c++ on a linux system. I am trying to ask the user for an x number of stars they want and when it prints out, if they say for ex 3. I want it to look like this:</p>
  
  <pre><code>***      ***
   ***    ***
    ***  ***
     ******
  </code></pre>
  
  <p>So it should print 3 stars on both sides but the 2nd line should start with 1 space and the 3rd line should start with 2 spaces. </p>
  
  <p>Print the first line with (user input) *, followed by 2(user input) spaces, then followed by (user input) *
  Print the second line with one space, followed by (user input) *, followed by 2N − 2 spaces, then followed by (user input) *
  Continue to print N + 1 lines</p>
  
  <p>I have attached pictures of my current code and the print out. I would like some guidance on how to get it to print all stars and how to do the spacing.</p>
  
  <p>Thank you</p>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main()
  {
      int n = 0;
      char star = '*';
      cout &lt;&lt; "Please enter a number." &lt;&lt; endl;
      cin &gt;&gt; n;
  
      for(int i = 0; i &lt;= n; i++)
      {
          cout &lt;&lt; "\n";
          for (int j = 0; j &lt;= n - i; j++)
          {
              cout &lt;&lt; " ";
          }
  
          for(int k = 1; k &lt;= i; k++)
          {
              cout &lt;&lt; "*";
          }
          cout &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Please enter a number.
  5
  
  
  
  
      .
     ..
    ...
   ....
  .....
  </code></pre>