Code :
#include <stdio.h>int main(){ int i, j; for (i = 5; i >= 1; i--) { for (j = 1; j <= i; j++) { printf("*"); } 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. The number of stars decreases with each row. -
Inner Loop (Columns): The inner
for
loop (j = 1 to j <= i
) prints stars (*
) starting from 1 up to the current row numberi
. -
New Line:
printf("\n");
moves the output to a new line after printing each row.
Output :
*****
****
***
**
*