0

I am missing one thing in the code because it's printing me the dots in every height case.. Can anyone give me a hint how to solve that ?

int main(void)
{
int n;
do
{
   n = get_int("Height: ");
}
while (n < 1 || n > 8);

for (int i = 0; i < n; i++)
{
        for (int k = 7; (k > i); k--)
        {
        printf(".");
        }
        for (int j = -1; j < i; j++)
        {
          printf("#");
        }
            printf("\n");
    }

}

2 Answers 2

0

simple. print spaces instead of dots.

    printf(" ");

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

Unfortunately it was not what I was missing :>. I needed to do that:

for (int k = n-1; (k > i); k--)
        {
        printf(" ");
        }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .