jeudi 24 octobre 2019

How Can I Draw Using Stars To "W" Letter With C

how can i draw a "W" pattern using only stars and with height input? For example: height of stars input: 5 output picture: https://i.ibb.co/47T7896/Ekran-Resmi-2019-10-25-00-20-04.jpg

Here is my code (it's working but input is broken and first star line are not including spaces):

#include<stdio.h>
#include<conio.h>

int main()
{
    int i,j,k,l,m,step=1;;
    printf("height of stars:");
    scanf("%d",&i);
    for (i=0;i<=4;i++)
    {

        for(j=0;j<=2;j++)
        {
            printf("*");
        }


        for(k=3;k>=i;k--)
        {
            printf(" ");
        }

        for(j=0;j<=2;j++)
        {
            printf("*");
        }

        for(l=1;l<=i;l++)
        {
            printf("  ");
        }

        for(j=0;j<=2;j++)
        {
            printf("*");
        }

        for(m=3;m>=i;m--)
        {
            printf("  ");
        }

        for(j=0;j<=2;j++)
        {
            printf("*");
        }
        step+=2;
        printf("\n");
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire