#include	<stdio.h>

#define MAX_COL 3

/* No need for function prototypes because all the functions
 * are defined before they are called.
 */

/* Add 1 to all elements in the 2-D array */
void addone(int ar[][MAX_COL], int nrows, int ncols)
{
	int	r, c;

	for (r = 0; r < nrows; r++)
		for (c = 0; c < ncols; c++)
			++ ar[r][c];
}

void display(int ar[][MAX_COL], int nrows, int ncols)
{
	int	r, c;

	for (r = 0; r < nrows; r++) {
		for (c = 0; c < ncols; c++)
			printf("%3d", ar[r][c]);
		putchar('\n');
	}

}

int
main()
{
	int twodim[][MAX_COL] = { { 1, 2, 3 },
			          { 4, 5, 6 } };

	addone(twodim, sizeof(twodim)/sizeof(twodim[0]),
			 sizeof(twodim[0])/sizeof(twodim[0][0]));
	display(twodim, sizeof(twodim)/sizeof(twodim[0]),
			 sizeof(twodim[0])/sizeof(twodim[0][0]));

	return 0;
}
