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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #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: