How to automatically highlight syntax of code displayed on page?
There are several options to highlight code.

From the modules available on d.o. -- GeSHi Filter and Syntax highlighter

A very recent module (yet to make it to Drupal.org) is Wiredcraft's highlight_js on GitHub. They provide a Drupal 7 only version, but (*shameless plug*) I've ported it to Drupal 6 -- https://github.com/ThinkFabrik/highlight_js/tree/6.x-1.0

Edit: depending on the module you may either have to create a new input filter or use Full HTML to get best results