There are several methods of adding program source code to a document - either
by using the verbatim environment which is built into LaTeX, or by
downloading the listings package.
The simplest method is to use a verbatim environment.
This requires no additional packages. To get a horizontal line above and
below (for example, when used with a figure environment) use
\makebox[\textwidth]{\hrulefill}
To refer to the code in the text body,
use the inline verb format: \verb!int m, n;!
If you wish to use a framed box, download the style file boxedminipage.sty (alternate site), It provides a new environment of that name, like a verbatim but with a frame around it.
The listings package provides many more features and flexibility:
language-aware syntax highlighting, listings spread over
several pages, and formatting options such as color and framed boxes.