title: Square with a diagonal, asterix pattern in C
body: <p>I have to write a program that will print a square made of asterisks with one diagonal, with the side of n asterisks. If n is 5, the pattern would be</p>
  
  <pre><code>*****
  *  **
  * * *
  **  *
  *****
  </code></pre>
  
  <p>My erroneous code is:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  main(){
    int n,row,i,star;
    scanf("%d",&amp;n);
    for(row=1;row&lt;=n;row++){
      if(row==1||row==n){
        for(i=1;i&lt;=n;i++){
      printf("*");
        }
      }
      else { for(star=1;star&lt;=n;star++){
          if((star==1)||(star=n-row+1)||(star==n))
            printf("*");
          else printf(" ");
         }
      }
  
      printf("\n");
    }
  }
  </code></pre>
  
  <p>Instead of doing its job, it prints infinite asterisks.</p>