Beginner

Print Number Pattern

Print pattern with numbers

This program prints a number pattern in a right triangle shape.

Program Code

number_pattern.c
C
1#include <stdio.h>
2
3int main() {
4 int rows;
5
6 printf("Enter number of rows: ");
7 scanf("%d", &rows);
8
9 for (int i = 1; i <= rows; i++) {
10 for (int j = 1; j <= i; j++) {
11 printf("%d ", j);
12 }
13 printf("\n");
14 }
15
16 return 0;
17}
Output

Enter number of rows: 5

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

Want to Learn More?

Explore our comprehensive tutorials for in-depth explanations of C programming concepts.

Browse Tutorials
Back to All Examples