Pass an array to a function
Can someone please narrate this code for me? I do not understand why we create:
1. void testfunc (int a[]) before main()
2. testfunc ( a) - in main()
3. void testfunc again after main.
can someone please explain the purpose of these? Thank you
Code:
void testfunc (int a[]);
void main()
{
int ctr, a[5] = {1,3,5,7,11};
testfunc(a);
for (ctr = 0; ctr < 5; ctr = ctr + 1)
{
printf("%d\n", a[ctr]);
}
}
void testfunc ( int a[] )
{
int n;
for(n = 0; n < 5; n = n + 1)
{
a[n] = a[n] * a[n];
}
}