L
Larry Doolittle
/* output the numbers entered. only print 8 numbers per line */
printf ("\nNumbers Entered:\n");
for (i = 0; i < MAX; ++i) {
if (list < 0)
break;
if (i % 8 != 0)
printf ("%-4d ", list);
else if (i == 0)
printf ("%-4d ", list);
else
printf ("%-4d\n", list);
}
This prints 9 numbers on the first line (i=0...8), and leaves a trailing
blank instead of \n at the end of the list (unless (MAX-1)%8==0). Your
one remaining use of break looks kind of silly, too. How about
/* output the numbers entered. only print 8 numbers per line */
puts ("\nNumbers Entered:");
for (i = 0; i < MAX && list < 0; ++i) {
if (i!=0) putchar ((i%8==0) ? '\n' : ' ');
printf ("%-4d", list);
}
putchar('\n');
I missed the beginning of this thread, so I'm not sure
if you really wanted to abort the display when you run
into a negative list element.
- Larry