Skip to content
Home » Half Triangle Star Pattern Program in C

Half Triangle Star Pattern Program in C

Learn about Half Triangle Star 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.

Half Triangle Star Pattern Program in C

Pattern:

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

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 13 in
Pattern Program 12 in C