problem printing arrays from a function

/***************
This function should print the current contents of a single array, with a caption (title) which is supplied as the first argument, and another array of int. When printing the numbers, print one line for the caption. Then print out the contents of the array one entry per line. Add a '$' before printing each amount.

This function will be called twice in main: once to show the contents of the sums array before it is sorted, and once to show the contents after it has been sorted.
****************/


void printArray(string caption, double array[], int size)
{
int i = 0; //keeps track of which array element is being processed
int perLine = 10; //gives a number of entries per line
int increment = 10; //gives the per line increment

cout << caption << endl;

do
{
for ( i; i < perLine; i++)
{
cout << setw(5)<< "$" << array[i];
}
cout << endl;

perLine += increment;
}
while (perLine <= size);

for (i; i < size; i++)
{
cout << setw(5) << "$" << array[i];
}
cout << endl;
}
Last edited on
Topic archived. No new replies allowed.