0

when I executed i have this error

:) mario.c exists

:) mario.c compiles

:) rejects a height of -1

:) handles a height of 0 correctly

:) handles a height of 1 correctly

*:( handles a height of 2 correctly \ expected output, but not " # # \n## ##\n"

:( handles a height of 23 correctly \ expected output, but not " # # ..."*

:) rejects a height of 24

:) rejects a non-numeric height of "foo"

:) rejects a non-numeric height of ""

https://sandbox.cs50.net/checks/763481501d3a4229a73e0426cc06ae1a

and this is my code

int main(void) { int h, s, d, r; do { printf("Height: "); h = get_int(); }
while (h < 0 || h > 23);

for (r = 1; r <= h; r++) 
{

    for (s = 0; s < h - r; s++)
    {
        printf(" ");}

    for (d = 0; d < r; d++)
    {
        printf("#");}

    for(s=0; s <2; s++)
    {
        printf(" ");
    }
    for (d = 0; d < r; d++)
    {
        printf("#");}

    for (s = 0; s < h - r; s++)
    {
        printf(" ");}

    printf("\n");

}

}

and when I used * instead of space it looks like this

enter image description here

4

check50 is expecting the last # on a line to be followed by the newline. It is complaining about the trailing spaces.

| improve this answer | |
  • Thank you so so much! – Saturn11 May 13 '17 at 19:02
  • I wasn't sure about this until I saw the walkthrough. They don't want the trailing spaces. – Michael Mathews May 20 '17 at 5:53
0

nothing much just change intial value of r... in your code r varies from 1-h..but change it to vary from r=0 r

| improve this answer | |

You must log in to answer this question.

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