Signup/Sign In

C Program To Print Hollow Pyramid Star Pattern

The Hollow Pyramid Star pattern is similar to the pyramid pattern, The major difference is all the characters inside the pyramid will be replaced by spaces.

Algorithm To Print Hollow Pyramid Star Pattern:

  • Print only one star in the first line
  • In other lines print almost two stars
  • by using the inner loop leave spaces between the stars
  • The no of rows will be multiplied by 2 then subtract the value by 1 and then print in the last row.

C Program To Print Hollow Pyramid Star Pattern:


int main() {
int i, space, rows, star=0;
printf("Enter The Number Of Rows To Print The Pyramid: \n");

/* Code Block To Print One Row In Every Iteration*/
for(i = 0; i < rows-1; i++) {
/* Printing spaces */
for(space = 1; space < rows-i; space++) {
printf(" ");
/* Code Block To Printing stars */
for (star = 0; star <= 2*i; star++) {
if(star==0 || star==2*i)
printf(" ");
/* Code Block To Print The Last Row */
for(i=0; i<2*rows-1; i++){
return 0;



About the author:
I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight