title: C pattern printing vertical numbers using for loop
body: <p>I am working on a pattern that prints the following code using for loop</p>
  
  <pre><code>1
  2 6
  3 7 10
  4 8 11 13
  5 9 12 14 15
  </code></pre>
  
  <p>code is as follows, which results in slightly wrong output.</p>
  
  <pre><code>main(){
     int i,j,k,n,num;
     printf("\n Enter no of rows: ");
     scanf("%d",&amp;num);
     for(i=1;i&lt;=num;i++,k=num){
        for(j=1,n=i;j&lt;=i;j++,n+=k){
          printf("%d ",n);
        }
     printf("\n");
     }
  }
  </code></pre>
  
  <p>And the code gives me this . 
  which is wrong from the output i wanted</p>
  
  <pre><code>1
  2 6
  3 7 11 
  4 8 12 16
  5 9 13 17 21
  </code></pre>