C Program to Print Number Pattern in pyramid format

C Program to Print Number Pattern in pyramid format 

For N=5,


1

1 2

1 2 3

1 2 3 4

1 2 3 4 5


  1. #include<stdio.h>
  2. int main()
  3. {
  4.  int i, j, n=5;
  5.  for(i=0; i<5; i++) //this loop tracks no. of lines
  6.  {
  7.   for(j=0; j<=i; j++)//this loop tracks numbers in a row
  8.   {
  9.     printf("%d ",j+1); //this line prints a number
  10.   }
  11.     printf("\n");
  12.  } 
  13.  return 0;
  14. }


Output

1
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5


Choose Next program from this list

Comments