0

I seem to be so close to the end of passing this assignment. My staircase seems to come out perfect, but when I go to check it with check50, I'm told that there appears to be something wrong with my spacing. If anyone could give a look at this and tell me what I'm doing wrong I'd really appreciate it.

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

int main(void)
{
    int height;
    int hashes;
    int spaces;

    do
    {
        printf("height:");
        height = get_int();
    }
    while (height < 0||height > 23);
    int i;
    for (i = 0; i < height; i++)
    {
        for (hashes = 0; hashes <= (i + 1); hashes++)
        {
            printf("#");
        }
        for (spaces = (height - i); spaces >= 1; spaces--)
        {
            printf(" ");
        }
        printf("\n");
    }
    return 0;
}
1

Your staircase has the stairs going down to the right. They're supposed to go up from the left. Perhaps a review of the assignment specification is in order?

There's a second problem lying in wait, but it's an easy fix so I'll let you find it.

You might also want to temporarily replace the space with a printable character for testing if you can't see the issue.

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

2
  • 1
    Sorry for the late reply, I was away from wifi for two days and just now saw this. Let me start by saying thank you so much for this help! With the first mistake, I guess I was so caught up on making my program work that I didn't even realize that my semi-pyramid was facing away from the flagpole, and was in complete mirror mode. However, I don't think I would have ever considered that I was including one too many spaces! Thank you so much for the tip, I really enjoyed finding that problem out on my own and having to find a solution. Jun 26 '17 at 17:31
  • You're welcome! Your reply perfectly explains the exact reason why this forum promotes giving direction rather than simply giving the answers!
    – Cliff B
    Jun 26 '17 at 18:27
0

The problem is in the order of the loops for more internal you must change the order, secondly the third, and thirdly the second

You must log in to answer this question.

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