⭐📚Intermediate
Print Inverted Hollow Star Pyramid
Print inverted hollow pyramid
Print an inverted hollow star pyramid with stars only on the borders.
C Program to Print Inverted Hollow Star Pyramid
inverted_hollow_pyramid.c
C
1#include <stdio.h>23int main() {4 int rows;5 6 printf("Enter number of rows: ");7 scanf("%d", &rows);8 9 printf("\n");10 11 for (int i = rows; i >= 1; i--) {12 // Print leading spaces13 for (int j = 0; j < rows - i; j++) {14 printf(" ");15 }16 17 // Print stars and hollow spaces18 for (int j = 1; j <= 2 * i - 1; j++) {19 if (i == rows || j == 1 || j == 2 * i - 1) {20 printf("*");21 } else {22 printf(" ");23 }24 }25 printf("\n");26 }27 28 return 0;29}Output
Enter number of rows: 5
*********
* *
* *
* *
*
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials