I think I wrote my code correctly. I used the same algorithm in Java and it gave me the perfect output. Can someone please tell me what's not working for this one and why it wont even comiple?

mod: (removed code per honor code guidelines. a bash error will not be because of the code itself anyway).

When i try to run it, it says: bash: ./mario: Permission denied

  • Hi, for future questions, when posting code, please add an extra carriage return before the code and 4 spaces at the start of each line so that it is treated as code and displayed as edited above. You can get more info on formatting by clicking on help at the top of the page. Also, you could benefit from running your code through style50. It makes it easier to read for all of us. thanks. ;-)
    – Cliff B
    Commented Jul 8, 2015 at 19:22

2 Answers 2


A bash permission denied error means that your executable doesn't have the correct permissions. Not sure how that might happen.

First, are you sure that your code is saved as mario.c? And that you have compiled it to mario using make?

If so, remove any existing mario executable using rm mario. Then, be sure you are in the same directory as your mario.c, run make mario and then run ./mario again.

It almost sounds like you are trying to execute the code itself, rather than the executable.

  • Thanks! I had another file named mario as well which is probably why it wasn't running. Sorry for the trouble. :) Commented Jul 9, 2015 at 11:50

It's a scope issue. You are probably getting an error that says height is undefined. The problem is that you defined it inside the do loop. Recall that the scope of a variable ends when the block of code finishes. In other words, it doesn't exist outside the curly braces surrounding it.

If this answers your question, please accept the answer to remove your question from the unanswered question pool. Let's keep up on forum maintenance. ;-)

  • Thanks. Now I initialized the height outside the loop to zero and inside it asks for the user input/ But it still shows the same error. Do you know what could still be the problem? Commented Jul 8, 2015 at 19:35
  • can you update the code andpost the exact error?
    – Cliff B
    Commented Jul 8, 2015 at 20:23

You must log in to answer this question.

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