Program in C To Print Left Arrow Star Pattern

Errorlogger
1
/* Program to print the following output

                  *****
             ****
        ***
    **
*
    **
         ***
              ****
                   *****
*/


#include <stdio.h>

int main()
{
    int i, j;

    //Prints the upper part of the arrow
    for(i=1; i<=5; i++)
    {
        //Prints trailing (5-rownumber) spaces
        for(j=1; j<=(5-i); j++)
        {
            printf(" ");
        }

        //Prints inverted right triangle
        for(j=i; j<=5; j++)
        {
            printf("*");
        }

        printf("\n");
    }

    //Prints bottom part of the arrow
    for(i=1; i<=5; i++)
    {
        //Prints trailing (rownumber-1) spaces
        for(j=1; j<i; j++)
        {
            printf(" ");
        }

        //Prints the right triangle
        for(j=1; j<=i; j++)
        {
            printf("*");
        }

        printf("\n");
    }

    return 0;
}

Post a Comment

1Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete
Post a Comment

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

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