I have pictures below. Please could you explain what I've done wrong?

enter image description here enter image description here enter image description here

  • 1
    It would be good to see the output from your program. What did you see when you entered, say, 4 as the height? Was the result the right height? Was it the right shape? If not, perhaps something is slightly wrong with the way you set a loop up.
    – bunstance
    Mar 20, 2015 at 9:00
  • check50 shouldn't really be the first and the only way you test your program. Try testing your program with different inputs. For example, what happens when the n is 1, 2, and 3? Do you think that should really happen? If not, how to fix it?
    – kzidane
    Mar 20, 2015 at 9:16
  • Caps does not help. Let's have a nice title, so we actually know what the question is? See the tour for how SE works.
    – Tim
    Mar 20, 2015 at 12:56
  • Why did you screenshot not copy / paste to the question or a pastebin?
    – Tim
    Mar 20, 2015 at 12:58

1 Answer 1


Your code is a little flawed. Did you trace it? Consider the case when n=1. When if reaches the loop, i=0. It will go to the test condition i < n-1, which will basically check if 0 < 0, because 1-1 is 0. This will evaluate to false and the control won't enter the loop, your code will exit. Hence the error says "Expected output not exit code of 0". This means that it expected some output on the terminal but instead your code just exited. This logic causes the other cases to fail as well.

Also, these are not the only cases for which your code fails, check50 checks with just these cases. Otherwise I think your code will fail for all cases. Try running the code separately using make and ./mario and see what output you get. Don't check your answer directly with check50.

Learning to trace your code and reading error messages will be very useful. Work a little with your code. It can be corrected. :)

You must log in to answer this question.

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