Program in C To Print Hollow Inverted Pyramid Star Pattern

Errorlogger
0
/* Program to print the following output
*********
*           *
*       *
*   *
*
*/


#include <stdio.h>
int main()
{
    int i, j;
    for(i=5; i>=1; i--)
    {
        //Prints trailing spaces
        for(j=i; j<5; j++)
        {
            printf(" ");
        }
        //Prints hollow pyramid
        for(j=1; j<=(2*i-1); j++)
        {
            if(i==5 || j==1 || j==(2*i-1))
            {
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !