Adding C++ code in Latex

My issue is that the font in the code appears different and apparently bigger than the other normal text of the document.Is it supposed to be like this or if not how can I specify a specific size for the font.Also is there a way were I can have a light background for the code something like what I have for the code above?

253k 70 70 gold badges 730 730 silver badges 796 796 bronze badges asked Jun 18, 2011 at 19:12 467 4 4 gold badges 8 8 silver badges 14 14 bronze badges Commented Jun 18, 2011 at 19:21

2 Answers 2

This is what you could have found out with the manual too and maybe faster than posting your question here ;-)

\documentclass \usepackage \usepackage \lstset < % language=C++, backgroundcolor=\color, % set backgroundcolor basicstyle=\footnotesize,% basic font setting > \begin Text before \dots \begin for (int i=0; i \end Text after it \dots \end

If this doesn't answer your question(s) please provide a full working minimal example which illustrates your problem and maybe you can describe the problem more precisely.