To show everyone's age and salary, you also need to use your
cout
inside the inner loop you've shown. You already done the calculations.
See also:
Basic Input/Output - C++ Tutorials[
^].
In this article, in particular, read the explanation about line breaks (search by "add line breaks at the end") — you will need line breaks between rows.
Note that the whole idea is not suitable to the task if you want to align columns properly; it's possible only if you know the string lengths of all fields and optionally use
\t
; in all cases, expect ugly result. The simplest way of nice formatting of the table would be generating, for example, HTML code with the
table
elements, which you can redirect to a file and view using any Web browser. Or you would have to write a GUI.
—SA