Actually, ROWS in the function definition does nothing at all. It's the same with or without it. The only reason you don't have to pass the number of rows as a parameter is that the constant ROWS is visible to the function.
I passed ROWS to the function simply because the function will work with a 2D array with any number of rows, but the array must have COLS columns.
EDIT: So the two ways you could code it are
Code:
int sum(int a[][COLS], int rows)
{
int r, c;
for (r = 0; r < rows; r++)
for (c = 0; c < COLS; c++)
// ...
}
or
Code:
int sum(int a[][COLS])
{
int r, c;
for (r = 0; r < ROWS; r++)
for (c = 0; c < COLS; c++)
// ...
}
But it's never necessary (or even useful) to put a number in the first array dimension in the function header.