0

this is my code, please tell what's wrong with it

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

int main(void)
{
    int height;
    do
    {
        height = GetInt();
    }while(height<=0 || height > 23);

    int space = height - 1;
    int temp = 1;
    int tempspace = space;

    for(int count = 1; count <= height;)
    {
        while(space != 0)
        {
        printf(" ");
        space--;
        }

        while(count != 0)
        {
            printf("#");
            count--;
        }

        printf("  ");

        count = temp;

        while(count != 0)
        {
            printf("#");
            count--;
        }

        printf("\n");

        temp++;
        space = tempspace - 1;
        tempspace--;
        count = temp;
    }
    return 0;
}

the error message I am getting is below.

:) mario.c exists
:) mario.c compiles
:( rejects a height of -1
   \ expected output, not a prompt for input
:( handles a height of 0 correctly
   \ expected output, not a prompt for input
:( handles a height of 1 correctly
   \ expected output, not a prompt for input
:( handles a height of 2 correctly
   \ expected output, not a prompt for input
:( handles a height of 23 correctly
   \ expected output, not a prompt for input
:( rejects a height of 24
   \ expected output, not a prompt for input
:( rejects a non-numeric height of "foo"
   \ expected output, not a prompt for input
:( rejects a non-numeric height of ""
   \ expected output, not a prompt for input
1

The error is \ expected output, not a prompt for input and it's quite literal. When executed, the program simply waits for a height to be input. The program spec says that there should be a prompt for input, Height:. It needs to print a prompt before waiting for input.

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

You must log in to answer this question.

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