Proper way to format computer code included in a thesis/dissertation
There are a number of excellent LaTeX packages for typesetting code, made for just such occasions.  The listings package is one good example, which includes standardized formatting for a number of languages.  

It does not provide a "definitive" way to typeset code (there is no such, since there are a number of competing conventions) but its defaults provide a standard and well-recognized formatting that is entirely appropriate for academic publications. Furthermore, it can be customized to follow any unusual requirements of your institutions thesis format.