Single dimensional arrays can be passed to functions as follows:-
float findaverage(int size, float list[])
{int i;
float sum=0.0;
for ( i=0; i<size, i++)
sum+ = list[i]
return(sum/size);
}
Here the declaration float list[] tells C that list is an array of float. Note we do not specify the dimension of the array when it is a parameter of a function.
Multi-dimensional arrays can be passed to functions as follows:
void printtable(int xsize, int ysize, float table[][5])
{ int x,y;
for (x=0, x<xsize; x++)
{ for(y=0; y<ysize, y++)
printf("\t%f",table[x][y]);
printf("\n");
}
}
Here float table[][5] tells C that table is an array of dimension Nx5 of float. Note we must specify the second (and subsequent) dimension of the array BUT not the first dimension.