User defined number of columns?
How would you go about assigning a table of data a specific number of columns, by a user defined function?
for example if you had:
Code:
#include <stdio.h>
#include <stdlib.h>
int columns, i;
int main()
{
printf("\nEnter number of columns [1 to 10]: ");
scanf("%d", &columns);
for (i=0; i<15; i++)
printf("%d ", i);
}
How would you modify this so that the variable 'columns' was the amount of entries in the line before a new line began. So say you entered 8, the output would be..
0 1 2 3 4 5 6 7
8 9 10 12 13 14
Thanks in advance!