C program to print pattern of an inverted pyramid using star

 

C program to print a pattern of an inverted pyramid/equilateral triangle using star

This C program is to print a pattern of an inverted pyramid/equilateral triangle using star(*).

* * * * *
* * * *
* * *
* *
*

If you need a dry run of the program or any other query, then kindly leave a comment in the comment box or mail me, I would be more than happy to help you.

Program

#include<stdio.h>
 
void main()
{
    int i,j,n;
 
    printf("Enter the number of line of *\n");
    scanf("%d",&n);
 
    for(i=n;i>=1;i--)
    {
        for(j=i; j<=n; j++)
        {
            printf(" ");
        }
        for(j=1; j<=i; j++)
        {
            printf("* ");
        }
        printf("\n");
    }
}

Output

inverted_triangle

Share Me!