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.
