0

I have written the code that makes the pyramid exactly how I am supposed to make it look. When I try it on my local computer, it works, but check50 doesn't agree. check50 displays "timed out while waiting for program to exit" message. How do I fix this? Here is my code and a picture to show the messages.

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

    void hash(int z);
    void space(int y);

    int main(void)
    {
        // get height
        int n;
        do
        {
            n = get_int("Height: ");
        }
        // make sure height is in the range of 4-8
        while (n < 4 || n > 8);
        // repeat height times
        for (int i = 0; i < n; i++)
        {
            int s = n - 1 - i;
            // Repeat height - i times (writes spaces)
            space(s);
            // Repeat i times (writes #'s)
            hash(i + 1);
            // The break in the ramps
            printf("  ");
            // Repeat i times (writes #'s again
            hash(i + 1);
            // Line break
            printf("\n");
        }

    }

    void hash(int z)
    {
        for (int x = 0; x < z; x++)
        {
            printf("#");
        }
    }

    void space(int y)
    {
        for (int j = 0; j < y; j++)
        {
            printf(" ");
        }
    }

check50 displays "timed out while waiting for program to exit" message

0

Take a close look at the check50 results. Does your code accept a height of 1 or 2 or 3?

check50 is timing out because the code is waiting for an answer that check50 doesn't provide.

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

| improve this answer | |

You must log in to answer this question.

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