Code samples and examples are quite common in every programming related websites. Its quite important to format the code samples to appear as it is coded in the IDE (platform in which code is developed, most common example being Eclipse, Jbuilder, Netbeans , etc). Joomla provides some awesome tools for code formatting and here is one which I am using in this website for highlighting the code samples: CodeHighlighter
1) download the plugin and install it in Extension manager
2) open the plugin manager and publish the plugin
3) now open the code highlighter from the plugin list and enable the programming language samples which you will be providing in your website , this is quite important , it avoids unnecessary loading of the java scripts for the programming languages which you will not be using in your website.
4) There is another plugin codehightlighter button plugin which helps in adding the customized tags to enable the formatting. Download that and publish it from plugins list.
5) In your articles , just click on Insert code button and add your code.
That's it :)