title: Printing diamond of stars
body: <p>I am printing diamond of stars but my code is compiling and running but it is only printing the half of diamond......anyone please help.</p>
  
  <p>below I have mentioned my code.
  I cannot understand the problem as why the system is only executing the first half and not the other half of diamond.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main()
  {
      int n,i=0,j;
      cin&gt;&gt;n;
  
      while(i&lt;=(n/2))
      {
      j=0;
      while(j&lt;(n/2)-i){
          cout&lt;&lt;" ";
          j=j+1;
  
      }
      j=0;
      while(j&lt;i+1){
          cout&lt;&lt;"*";
          j=j+1;
      }
      j=0;
      while(j&lt;=i-1){
          cout&lt;&lt;"*";
          j=j+1;
      }
      cout&lt;&lt;"\n";
      i=i+1;
      }
  
  while(i&lt;=(n/2))
  
        {
          j=0;
          while(j&lt;(n/2)-i)
          {
              cout&lt;&lt;" ";
              j=j+1;
  
          }
          j=0;
          while(j&lt;i)
              {
              cout&lt;&lt;"*";
              j=j+1;
              }
          j=0;
          while(j&lt;i-1){
              cout&lt;&lt;"*";
              j++;
          }
          cout&lt;&lt;"\n";
          i--;
        }
  
  return 0;
  }
  </code></pre>