While this isn't exactly rocket science, it may be helpful to someone. In my experience, when you try to include code in a WordPress page or post, it will convert quotation marks into fancy quotation marks, which makes the code useless if you want to cut and paste it. If you try to enter certain types of code (html, for example), WordPress is likely to interpret it instead of displaying it. You can get around this problem with a plugin that utilizes Alex Gorbatchev’s SyntaxHighlighter project.
The plugin SyntaxHighlighter Evolved allows you to wrap your code in "sourcecode" tags, protecting it from the WordPress forced beautification. It's used like this:
You can find the list of supported languages at this WordPress.com support page.
This plugin is already included in WordPress.com blogs, and is easily installable on self-hosted (WordPress.org) blogs.
Note that, at least in the WordPress.org implementation, you can usually shorten the tag to just the language name. This is probably true in WordPress.com as well, I just haven't tried it.