WAP in C to Print Star Pattern with Underscore

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

 #include <stdio.h>
int main()
{
    int i, j,n;
    printf("enter number=");
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        //Prints trailing spaces
        /*for(j=i; j<n; j++)
        {
            printf(" ");
        }*/
        //Prints hollow right triangle
        for(j=1; j<=(i*i); j++)
        {
            if(j==1||j==(i*i))
            {
                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 !