Code :
#include <stdio.h>int main(){ int i, j; for (i = 5; i >= 1; i--) { for (j = 5; j >= i; j--) { printf("%d", i); } printf("\n"); } return 0;}
-
Header File:
#include <stdio.h>
is needed to useprintf()
for printing output. -
Main Function: The program starts from
int main()
. It returns 0 to indicate successful completion. -
Outer Loop (Rows): The outer
for
loop (i = 5 to i >= 1
) controls the number of rows. Each row contains the row number printed multiple times. -
Inner Loop (Columns): The inner
for
loop (j = 5 to j >= i
) prints the current row numberi
. Asi
decreases, the number of timesi
is printed increases. -
New Line:
printf("\n");
moves the output to a new line after printing each row.
Output :
5
44
333
2222
11111