C program to print pyramid pattern containing numbers in series pattern.
For n=4,
1
2 3
4 5 6
7 8 9 10
- #include<stdio.h>
- int main()
- {
- int i, j, n, count=1;
- printf("Enter your number:");
- scanf("%d", &n);
- for (i=0; i<n; i++)
- {
- for(j=0; j<=i; j++)
- printf("%d ", count++);
- printf("\n");
- }
- return 0;
- }
Output
Enter your number:4
1
2 3
4 5 6
7 8 9 10
Comments