To print a hollow inverted pyramid pattern in C, we use nested loops to manage spaces and stars.
In this example,
#include <stdio.h>
int main() {
int row, space, numRows;
numRows = 5;
for (row = numRows; row >= 1; row--) {
for (space = 0; space < numRows - row; space++) {
printf(" ");
}
if (row == numRows || row == 1) {
for (space = 1; space <= 2 * row - 1; space++) {
printf("*");
}
} else {
printf("*");
for (space = 1; space <= 2 * row - 3; space++) {
printf(" ");
}
if (row != 1) {
printf("*");
}
}
printf("\n");
}
return 0;
}
********* * * * * * * *
In this tutorial, we learned How to print Hollow Inverted Pyramid Pattern in C language with well detailed examples.