A Pyramid is “properly aligned and formatted,” it means that the stars forming the pyramid shape are centered and symmetrically arranged, making the pattern look visually balanced and aesthetically pleasing. Specifically:
Centered Alignment: The stars in each row are centered relative to the width of the pyramid, ensuring that the shape appears symmetrical. This is achieved by adding the correct number of leading spaces before the stars in each row.
Consistent Formatting: The number of stars increases consistently by two in each subsequent row, creating a visually appealing pyramid structure. The pattern starts with one star at the top and adds two more stars in each row below, ensuring the pyramid expands evenly.
Example:
For n = 5, the output will be:

Key Points:
- Leading Spaces: The spaces before the stars in each row ensure the stars are centered.
- Row 1: 4 spaces + 1 star
- Row 2: 3 spaces + 3 stars
- Row 3: 2 spaces + 5 stars
- Row 4: 1 space + 7 stars
- Row 5: 0 spaces + 9 stars
- Increasing Stars: The number of stars increases by 2 for each subsequent row, maintaining a proper pyramid shape.
Following is a program to print a FULL-PYRAMID :
#include<stdio.h>
int main(){
int n,step=1;
printf("Input the number of rows ");
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=n-1;j>=i;j--){
printf(" ");
}
for(int k=1;k<=step;k++){
printf("*");
}
step +=2;
for(int q=n-1;q>=i;q--){
printf(" ");
}
printf("\n");
}
return 0;
}Explanation:
- Input Prompt:
printf("Input the number of rows: ");prompts the user to enter the number of rows for the pyramid. - Reading Input:
scanf("%d", &n);reads the input value for the number of rows. - Outer Loop:
for (int i = 1; i <= n; i++) { ... }iterates over each row. - Leading Spaces:
for (int j = n - 1; j >= i; j--) { printf(" "); }prints leading spaces to center-align the stars. - Stars:
for (int k = 1; k <= step; k++) { printf("*"); }prints the stars in each row. - Increment Step:
step += 2;increases the number of stars for the next row. - Trailing Spaces:
for (int q = n - 1; q >= i; q--) { printf(" "); }prints trailing spaces (optional for symmetric padding). - New Line:
printf("\n");moves to the next line after completing a row.