- 1C Program - Print Simple Pyramid Pattern
- 2C Program - Print Given Triangle
- 3C Program - Print 180° Rotation of Simple Pyramid
- 4C Program - Print Inverted Pyramid
- 5C Program - Print Number Pattern
- 6C Character Pattern Program
- 7C Hollow Star Pyramid Pattern
- 8C Floyd's Triangle Program
- 9C Pascal's Triangle Program
C Program – Print Number Pattern - Incremental Sequence
Print Number Pattern
This pattern prints numbers incrementally in each row. The first row prints 1, the second row prints 1 2, the third prints 1 2 3, and so on. It forms a staircase of increasing sequences.
#include <stdio.h>
int main() {
int rows;
printf("Enter number of rows: ");
scanf("%d", &rows);
for (int i = 1; i <= rows; i++) {
// Print numbers from 1 to i
for (int j = 1; j <= i; j++) {
printf("%d ", j);
}
printf("\n");
}
return 0;
}
Enter number of rows: 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Each row begins at 1 and prints consecutive integers up to the row number. This creates a simple, increasing pattern that helps beginners understand nested loops with varying ranges.
Comments
Loading comments...