Inverted hollow Triangle Star pattern in C

In this tutorial, we will write a C program to display a hollow inverted triangle star pattern. Before that, you may go through the following topics in C.

Inverted hollow Triangle Star pattern in C

It is also called Hollow Pyramid Star Pattern in C.

#include <stdio.h>

int main()
{
  int i, j, k, m = 1, rows;

  printf("Enter the no. of rows: ");
  scanf("%d", &rows);

  for (i = rows; i >= 1; i--)
  {
    for (j = 1; j < m; j++)
      printf(" ");

    for (k = 1; k <= 2 *i - 1; k++)
    {
      if (k == 1 || k == 2 *i - 1 || i == rows)
        printf("*");
      else
        printf(" ");
    }
    m++;

    printf("\n");
  }

  return 0;
}

Output:

inverted hollow triangle pattern in c