Hollow Pyramid Pattern
Here you will learn to print a Hollow Pyramid Pattern in C programming language.
Program Code
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 29 | #include <stdio.h> int main() { int i,j,num; printf("Enter a Number to print Square Pattern : "); scanf("%d",&num); for (int i = 0; i < num; i++) { for (int j = 0; j < 2 * (num - i) - 1; j++) { printf(" "); } for (int k = 0; k < 2 * i + 1; k++) { if (k == 0 || k == 2 * i || i == num - 1) { printf("* "); } else { printf(" "); } } printf("\n"); } return 0; } |
Output