Star Pyramid

 #include <stdio.h>

int main() {
    int rows;
    printf("Enter the no. of rows: ");
    scanf("%d",&rows);
    for (int i=1;i<=rows;i++){
        for (int j=1;j<=rows-i;j++){
            printf(" ");
        }
        for (int k=1;k<=i;k++){ //for 1 3 5 stars 2*i-1
            printf("* ");       // remove space after *
        }
        printf("\n");
    }

    return 0;
}


Enter the no. of rows: 5 * * * * * * * * * * * * * * *

Comments

Popular posts from this blog

Transpose

1 to n without any parameter Recursion

Recursion Factorial