Write a function which finds a maximum out of two user supplied numbers.
Run several times the command:
pdflatex sample_report.tex
Latex takes care of the page numbering and references to the listing thus several executions are required. This is similar to the execution of the parser, compiler, and linker for compiling languages.
I strongly recommend to learn how to use LaTeX for report writing. While it is not as obvious to use as conventional word processing software, it saves a lot of time taking formating task away from you. Note in above example how listing of the program formatted without any effort from the user.
Below is a link to The not so Short Introduction to LaTeX.
Please see a sample tex file and resulting pdf file