- 1C Program - Print Simple Pyramid Pattern
- 2C Program - Print Given Triangle
- 3C Program - Print 180° Rotation of Simple Pyramid
- 4C Program - Print Inverted Pyramid
- 5C Program - Print Number Pattern
- 6C Character Pattern Program
- 7C Hollow Star Pyramid Pattern
- 8C Floyd's Triangle Program
- 9C Pascal's Triangle Program
C Program - Print Hollow Star Pyramid
#include <stdio.h>
int main() {
int i, j, space, rows = 5;
for(i = 1; i <= rows; i++) {
// Print leading spaces
for(space = 1; space <= rows - i; space++)
printf(" ");
// Print stars and hollow spaces
for(j = 1; j <= 2*i - 1; j++) {
if(j == 1 || j == 2*i - 1 || i == rows)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
*
* *
* *
* *
*********
Comments
Loading comments...