Skip to content
Home » Equilateral Triangle Pattern Program in C

Equilateral Triangle Pattern Program in C

Learn about Equilateral Triangle Pattern Program in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Equilateral Triangle Pattern Program in C

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

Program:

#include<stdio.h>
int main()
{
    int n, r, c, s;

    printf("Enter number of rows: ");
    scanf("%d",&n);

    for(r=1;r<=n;r++)
    {
      for(s=1;s<=n-r;s++) printf(" ");
      for(c=1;c<=r;c++) printf("* ");

      printf("\n");
    }

    return 0;
}

Output:

Enter number of rows: 5
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Pattern Program 14 in C
Pattern Program 13 in