In most situations, you want to use code formatting. If you are expecting a certain output, you probably have a specific nature as what the lines should be outputted, so using code formatting lets you keep everything that should be on one line in one line. This is superior to block quotes, which will wrap if it is too long. Any additional formatting should match how the output should be.
The only real downside to code formatting your expected output/input is that when it isn't code, you can get some wonky coloration. This actually looks pretty good in some cases, but if you find that the resulting coloration for a particular output is very distracting or makes the text seem unreadable, then you can opt to use block quotes instead.