For once I actually have the full program working. The only issue I am having is this. The last number of the row that is printed needs to not have a , after it. The program works if a number that is divisible by 10 is enter but if it is not there is a , after it. Can anyone help lead me down the correct way to format the function to print the way I need it.

Here are the exact instructions for how it should work : print the values in the array. The values must be displayed with 10 integers per line and a comma after each value. The last value on each line does not have a comma after it. The last line may have fewer than10 values if the total numbers of values printed is not evenly divisible by 10. For example, if the user asked for 15 array elements to be printed, then the last line would only have 5 values; or if the user asked for 92 values, then the output would be 9 lines containing 10 values and the last output line would have only 2 values.

Here is what I have currently for the function:

Code:
void printArray (int array[], int n)
{
  for (int y = 0; y < n; y++)
 {
    cout<< array[y];


    if( (y % 10) == 9)
    {
        cout << endl;
    }


    else
        cout << ", ";
 }
    cout << endl;


   }