Technically, there is nothing special about showing code on a WordPress site. You just wrap code in
<pre> (and probably
<code>, for semantics and font control) tags, like:
Then you style up the code with CSS like you would any other element. Perhaps you set your code in your favorite monospace font (not required, but keeps indentation nice) and set off your pre tags visually with a dark background.