Code :
#include <stdio.h>int main(){ int i, j; for (i = 1; i <= 5; i++) { for (j = 5; j >= i; j--) { printf("%d", j); } 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 = 1 to 5
) controls the number of rows. In each row, numbers will be printed in descending order, starting from 5. -
Inner Loop (Columns): The inner
for
loop (j = 5 to j >= i
) prints numbers starting from 5 down to the current row numberi
. -
New Line:
printf("\n");
moves the output to a new line after printing each row.
Output :
54321
5432
543
54
5