Home > Programming > Functions using the "C" programming language > example04.c |
/*
In this example we demonstrate how to pass a two dimention array
as paramenter in a function
*/
#include <stdio.h>
#define ROWS 2
#define COLUMNS 3
/*
Function prototype
*/
void print_2D(int
[][COLUMNS],int);
void main(void)
{
int nums[ROWS][COLUMNS]={ { 1, 2, 3 }, {
4, 5, 6 } };
print_2D( nums, ROWS );
}
/* Print the array elements */
void print_2D(int
a[][COLUMNS], int r)
{
int i,j;
for( i=0; i<r; i++)
{
for( j=0;
j<COLUMNS; j++ ) printf("%d ",a[i][j]);
printf("\n");
}
}
© 2004 Jim Valavanis