title: I have following code for image provided in the link.After n=2 I cant iterate spaces,please guide me through it
body: <p>I am new to stackoverflow so please forgive for any mistakes.</p>
  
  <pre><code>#include void main() { int i,j,p,n,s; printf("Enter rows:\n"); scanf("%d",&amp;n); if(n==1) { for(i=1;i&lt;=n+2;i++) { for(j=1;j&lt;=i;j++) { printf("* "); } printf("\n"); } } else { for(i=1;i&lt;=3;i++) { for(j=1;j&lt;=i;j++) { printf("* "); } printf("\n"); } for(p=1;p&lt;=n-1;p++) { for(i=1;i&lt;=2;i++) { for(j=3;j&lt;=3;j++) { printf(" "); for(j=1;j&lt;=i+1;j++) { printf("* "); } } printf("\n"); } } } }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/NjGs4.jpg" alt="enter image description here"></p>