'Pretty' code listings are sometimes considered worthwhile by the neurotically æsthetic programmer, but they have a serious place in the typesetting of dissertations by computer science and other students who are expected to write programs. Simple verbatim listings of programs are commonly useful, as well.
Verbatim listings are dealt with elsewhere. The problem of typesetting algorithm specifications is also discussed in another question)}.
The listings package is widely regarded as the best bet for formatted output (it is capable of parsing program source, within the package itself), but there are several well-established packages that rely on a pre-compiler of some sort.
The lgrind system is a well-established pre-compiler, with all the facilities one might need and a wide repertoire of languages.
The tiny_c2l system is more recent: users are encouraged to generate their own driver files for languages it doesn't already deal with.
The C++2LaTeX system comes with strong recommendations for use with C and C++.
The highlight system is a general converter, that can produce HTML and RTF formats as well as (La)TeX. It claims to be highly customisable, and the distribution comes with a wide range of language definitions. Documentation is provided by the README file in the distribution, which describes itself as a manual.
This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=codelist