title: how to add space to the following star pattern?
body: <p>How is it possible to print the following pattern?</p>
  
  <pre><code>    *
     **
    ***
   ****
  *****
  ****
  ***
  **
  *
  </code></pre>
  
  <p>How can we add the spaces during the first half of the pattern?
  I only managed to get the second half of the pattern right:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void printpattern(int n)
  {
      for (int r = 0; r &lt;= n; r++)
      {
          for (int z = 0; z &lt;= r; z++) {
              cout &lt;&lt; "*";
          }
  
          cout &lt;&lt; endl;
      }
  }
  
  int main()
  {
      int n = 5;
      printpattern(n);
  }
  </code></pre>