[Tex/LaTex] Integer arithmetic in TeX

counters

After many years of being merely a regular TeX (LaTeX lately) I started reading little bit more recently. I wrote a small program (very naive) which is suppose to illustrate doing integer arithmetic in TeX.

\message{Please enter the first number:}
\read-1 to \first

The first entered number is \first

\count0=\first

\message{Please enter the second number:}
\read-1 to \second

\count1=\second

The second entered number is \second

\advance\count0 by \count1


Could you please compare the sum of number you have entered and
the number of the page :)
\bye

Is there a simple way to recover the content of register \count0 on an arbitrary place on the page?

Best Answer

In order to obtain \count0, use \the\count0. This will typeset the value of \count0 wherever it is used.

enter image description here

\message{Please enter the first number:}
\read-1 to \first

The first entered number is \first

\count0=\first

\message{Please enter the second number:}
\read-1 to \second

\count1=\second

The second entered number is \second

\advance\count0 by \count1


Could you please compare the sum of number you have entered and
the number of the page :) \the\count0
\bye
Related Question