Login to ask a question from Pattern Printing in C

C program to print following Pyramid:

    **********

    ****  ****

    ***    ***

    **      **

    *        *

#include
int main()
{
    int n,i,j;
    int space=0;
    printf("Enter the number of rows:\n");
    fflush(stdout);
    scanf("%d",&n);
    /*run loop (parent loop) till number of rows*/
    for(i=n;i>0;i--)
    {
        /*print first set of stars*/
        for(j=0;j< i;j++)
        {
            printf("*");
        }
        for(j=0;j< space;j++)
        {
            printf(" ");
        }
        /*print second set of stars*/
        for(j=0;j< i;j++)
        {
            printf("*");
        }
        printf("\n");
        space+=2;
    }
    return 0;
}
Previous Question Next Question
🔗

Similar Questions

From Pattern Printing in C · C programming

View All
WhatsApp