Pyramid Star Pattern in C Language

Pyramid Star Pattern

Pyramid Star Pattern is consists of rows where each row has increasing number of stars which form a triangular shape. The stars in Pyramid Star Pattern lie center in each row, surrounded by spaces to create a Pyramid Structure. The number of rows determine the height of Pyramid.

Output

Enter the number of rows: 5
    *
   ***
  *****
 *******
*********
Free Hand-Written Notes

Codes

#include <stdio.h>

int main() {
    int rows, i, j;

    printf("Enter the number of rows: ");
    scanf("%d", &rows);

    for (i = 1; i <= rows; i++) {
        for (j = 1; j <= i; j++) {
            printf("* ");
        }
        printf("\n");
    }

    return 0;
}

Conclusion

Creating a Pyramid Star Pattern in C Language is an excellent exercise for beginners to boost the knowledge of Loop Structure and Logical Thinking.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top