How to write a C Program Nested Loop (inverted Triangle) C Code in C Programming Language ?
Here is a C Code for Nested loop ( inverted Triangle) with Output.
Solution:
- #include<stdio.h>
- int main()
- {
- int i,j,k,l;
- for(i=1;i<=5;i++)
- {
- for(j=1;j<=i;j++)
- {
- printf(" ");
- }
- for(k=5;k>=i;k--)
- {
- printf("*");
- }
- for(l=i;l<=4;l++)
- {
- printf("*");
- }
- printf("\n");
- }
- }
- /* Output will be like
- *********
- *******
- *****
- ***
- *
- */