Had to do a little searching for this one. But turns out there is a pretty simple way. Get this plugin http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/ and then use this syntax
your code here
More info here: Options for displaying source code in post