3

I have a program I found on the Internet and I don't understand why its output is like the one shown.

Therefore, is it okay to ask about the order of execution that a program goes through? For example, an answer could be:

The program goes through a iteration (for).

The program goes through X method and (...).

If someone gives me an explanation like this above I will understand the program's output.

2
  • @gnat No, I meant like the answer of Robert. Mar 7, 2016 at 21:21
  • 1
    SO contributors are NOT remote debugging slaves! Mar 7, 2016 at 22:19

2 Answers 2

7

In most cases - no, it would not be welcome.

The author of the question is expected to at very least read code, and in most cases run the code and step with debugger(unless it is something like FORTRAN conversion question where one unlikely have necessary tools/skills handy to try). Otherwise flood of downvotes is completely expected.

If code is still unclear at that point you can ask question with supporting information. Make sure so that it is not "coding puzzle" kind of question but rather practical code one plausibly need in real life.

It may be good idea to try coming up with alternative implementation to show both in the question like "I'd implement it that way, but here is approach found online that possible is better - I don't understand how line xxx solves the problem".

7

Implementors of most programming languages provide debuggers these days. If you want to know how a program works, attach a debugger to it, and step through it one line at a time.

If you haven't at least done that you'll likely get downvoted for lack of research effort.

2
  • 2
    I agree with this sentiment. In chat we get a rather constant stream of users who want a quick explanation of why X doesn't work. We often have a message along the lines of If you haven't debugged your code, please do so before asking us how to fix it pinned.
    – Travis J
    Mar 7, 2016 at 21:22
  • 1
    @TravisJ Yes, such a message is useful. OK, it almost never has the effect asked for; the user often just deletes the question when it realises that it's not going to get its copied homework fixed for free, but that's one less bad question anyhow:) Mar 7, 2016 at 22:23

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