C Program To Print Inverted Triangle Star Pattern
In this tutorial, we are going to see how to write a C program to print inverted or reverse triangle star patterns. To print a pyramid or an inverted triangle of N lines made of stars, We use for loop. Below is the logic for displaying a pyramid or an inverted triangle of N lines made of stars in C programming.
Input :
Number of Lines: 5
Output :
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
C Program To Print Inverted Triangle Star Pattern
#include <stdio.h>
int main()
{
int i, j, lines, s=0;
printf("Enter the number of lines: ");
scanf("%d",&lines);
printf("\n");
for(i=lines; i>=1; i--)
{
for(j=1; j<=s; j++)
printf(" ");
for(j=1; j<=i; j++)
printf("*");
for(j=i-1; j>=1; j--)
printf("*");
printf("\n");
s++;
}
return 0;
}
Output:
Entrez le nombre de lignes: 5
*********
*******
*****
***
*




