I created this function that scans a 2D array for vertical pairs, where row = 20 and column = 30. To clarify random characters from A to Z are stored in each of the array's elements.
char function3 (char randchar_array[ROW] [COLUMN])
{
int r = 0 ;
int c = 0 ;
int vertpairs = 0;
for (r = 0; r < ROW ; r++)
{
for (c = 0; c < COLUMN -1; c++)
{
{
if(randchar_array[r][c] == randchar_array[r+1][c])
vertpairs++;
}
}
}
return (vertpairs);
}
My question is: Is the -1 necessary for the 2nd for statement " for (c = 0; c < COLUMN -1; c++)."