Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing certain number of characters per line

Status
Not open for further replies.

DerPflug

Programmer
Mar 28, 2002
153
US
I have an array of integers that I want to print a certain number of characters per line. For instance, I have an array of 10 integers and I want to print 3 integers per line:

9 1 8 3 7 3 7 4 6 5

to print like this:

9 1 8
3 7 3
7 4 6
5

Thanks in advance.
 
Hi:

As you loop thru your array, do some modulo arithmetic dividing by 3 (the number of elements you want per line):


((cnter++) % 3) == 0)

if that results equals 0 print out the element with a new-line else print the element with no new-line.

Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top