[SOLVED] Incomplete stairway in C


So what I need to have as a finished product is a program that:

  • Asks for an int and only continues if the given is between one and eight. (Finished)
  • When given the number "8" a stairway that has eight hashtags in it’s bottom row must appear. (Finished)
  • The stairway must be right-aligned, so there must be spaces printed to make the top right hashtag align with the bottom right hashtag. (Incomplete)
  • When the stairway is given the number "1" it must simply print a single hastag. (Incomplete)

My code is as follows:

int main (void)
    int height = 0;
    int change;
    int row;
    int space;
        height = get_int("Height: ");
    } while(height < 1  || height > 8);

    for (change = 0; change < height; change++ )
        for (space = 7; space > change; space--)
            printf(" ");

        for (row = -1; row < change; row++)


PLease can someone tell my which functions I need to implement so I can complete the final two criteria?


Change the starting value of space so it depends on the height, so you don’t print more spaces than needed.

        for (space = height-1; space > change; space--)
            printf(" ");

Answered By – Barmar

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *