‘C’ program to display n lines of the pattern.

C File =>


/* Write a ‘C’ program to display n lines of the following pattern. 
 1 
 2 3 
 4 5 6 */

#include<stdio.h>
int main() 
{
      int i,j,n=1;
 
      for(i=1;i<4;i++)
     {
         for(j=1;j<=i;j++)
         {
             printf("%d\t",n);
             n++;
          }
         printf("\n");
     }

     return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.