It is a bit difficult for me to understand what this question is asking, but I think what you're asking is whether it's necessary for a question to explicitly state the relevant error messages, since the error messages could be obtained by merely running the code through a compiler.
The answer to that is yes, it is absolutely necessary that the error message(s) appear in the text of the question itself. This is stated in our guidelines for on-topic questions—namely:
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example.
Notice the requirement that "a specific problem or error" be included "in the question itself".
If the question does not include this, that is grounds for closing the question for precisely the reason quoted above.
The reason why this requirement exists is that someone should not have to precisely reproduce your development environment in order to attempt to answer your question. If they're familiar with the technologies involved, they should be able to answer just by looking at your question. You want to make it easy for people to answer your question, not hard.
As for that question you happened upon, it merely says:
I'm stuck at how to decrement the last value by 1.
That is the entirety of the problem statement. It is anyone's guess where the asker is "stuck". That doesn't tell us anything useful. A guess is not the starting point for a good answer.
In this particular case, the task is simple enough that people can just solve the exercise themselves and post code, but that's not actually a good question. Stack Overflow is not a code-writing service, it's a Q&A site. Code dumps are not good answers. If an answer doesn't address the asker's specific point of confusion, then it is not a good answer.
The only possible hope for an answer to this question to meet our standards would be for it to explain in detail how loops and output work, but since the asker provided no starting point for his knowledge or hint as to where his confusion lies, the answer would essentially have to cover everything that an introductory programming text covers. That would make the answer far too long for the Q&A format, and thus the question too broad.