0
#include <stdio.h>
#include <cs50.h>

int main (void)

{

    int n;

    do
    {
        printf("Height:");
        n=GetInt();

    }
    while (n >23 || n < 0 );


    for (int x = 0, m = 22;  x < n; x++, m--)


        {

            for (int z = 0; z < m;  z++)
            {
                printf(" ");


            }
              for (int y = -2 ; y < x; y++)
              {

                   printf("#");

              }

                     printf("\n");


        }

}

can u tell me how to fix the spaces because line one and two cant handle height right . I think something is wrong with that m22 because on first line i get 22 spaces insteed zero :)

1

m = n

It's going to repeat until the condition is no longer true, so right now it is repeating until m >= 22. You want the number of repetitions equal to your height.

2
  • Thanks for good answer! :) figured it out yesterday on my own :) Apr 5 '16 at 5:36
  • Zombie Question. @MariusGaigalas, please come back and accept the answer. Otherwise, this Zombie Question will remain marked as unanswered and continue to haunt the forum forever. Sep 13 '16 at 18:41

You must log in to answer this question.

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