Output a number of items per line

Assuming I have a simple output from 1 - 20. How can I output five numbers per line? I'm thinking this is suppose to be easy but I'm definitely having problems. Thanks.
Last edited on
Just don't put an endl til after the 5th number.
Hey

Here's some pseudocode to help you along:

1
2
3
4
5
6
7
8
9
printNums
  for(i in 1..20)
    print i
    if(i%5==0) 
      print endl
    end if
  end for
end printNums
    


Generally, if you have to do something "every n'th time" you should instantly think "modulo"
Last edited on
There are multiple ways to solve a problem as well, You could also solve that problem using nested for loops.
Last edited on
Thanks guys...appreciate it very much
Topic archived. No new replies allowed.