Printing in nice columns.
I need to print some integers in ten nice columns. I can't seem to figure out how to stop the columns at the tenth and continue down a line.
Use the modulo operator (%) to see if you have output ten items.
In this example, I output four lines of five items each.
1 2 3 4 5
|
for (int i = 0; i < 20; i++)
{
cout << "x ";
if ((i % 5) == 0) cout << endl;
}
|
Hope this helps.
Last edited on
Topic archived. No new replies allowed.