title: Print a diamond shape with a borderusing asterisks in C/C++
body: <p>I need to print out a diamond shape with a border using asterisks in C/C++</p>
  
  <p>The code below renders only the diamond, but what I need is one what a border. what should I do?</p>
  
  <p>Expectation:</p>
  
  <p><img src="https://i.stack.imgur.com/8j2IL.jpg" alt="diamond with border"></p>
  
  <p>Reality:</p>
  
  <p><img src="https://i.stack.imgur.com/6J15u.jpg" alt="diamond without border"></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  void PrintDiamond(int iSide) {
      using namespace std;
      int iSpaces = iSide;
      int iAsterisks = 1;
      // Output the top half of the diamond
      for (int iI = 0; iI &lt; iSide; ++iI) {
          for (int iJ = 0; iJ &lt; iSpaces; ++iJ) {
              cout &lt;&lt; " ";
          }
          for (int iJ = 0; iJ &lt; iAsterisks; ++iJ) {
              cout &lt;&lt; "*";
          }
          cout &lt;&lt; endl;
          --iSpaces;
          iAsterisks += 2;
      }
      // Output the bottom half of the diamond
      for (int iI = 0; iI &lt;= iSide; ++iI) {
          for (int iJ = 0; iJ &lt; iSpaces; ++iJ) {
              cout &lt;&lt; " ";
          }
          for (int iJ = 0; iJ &lt; iAsterisks; ++iJ) {
              cout &lt;&lt; "*";
          }
          cout &lt;&lt; endl;
          ++iSpaces;
          iAsterisks -= 2;
      }
  }
  
  int main()
  {
      // Print a diamond with side = 4
      PrintDiamond(4);
  
      return 0;
  }
  </code></pre>