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
- #include<stdio.h>
- int main()
- {
- int i, j, n=5;
- for(i=0; i<5; i++) //this loop tracks no. of lines
- {
- for(j=0; j<=i; j++)//this loop tracks numbers in a row
- {
- printf("%d ",j+1); //this line prints a number
- }
- printf("\n");
- }
- return 0;
- }
Output
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Comments