Example 1 — Shrink the row with the outer loop
Start row at 5 and stop at 1. The inner loop prints 1 through row.
#include <stdio.h>
int main(void) {
int rows = 5;
for (int row = rows; row >= 1; row--) {
for (int n = 1; n <= row; n++)
printf("%d", n);
printf("\n");
}
return 0;
} How It Works
row--makes each later line one digit shorter.- The inner
foralways restarts at 1, so every row begins with 1. printf("%d", n)prints theint;printf("\n")ends the row.

