// MAIN FUNCTION
void main()
{
int a[100], aeven[100];
/*
...Statements...
*/
aeven[100] = alleven(a, n);
}
// FIND ALL EVEN FUNCTION
int alleven(int a[], int n)
{
int aeven[100];
int i, j=0;
for(i=0;i<n;++i)
{
if(a[i]%2==0)
{
aeven[j]=a[i];
++j;
}
}
return aeven;
}
It doesn't work, how can I return the aeven from the alleven function to the aeven in the main ?
If you pass an array to a function, it is automatically passed by reference. So what ever changes are made to the array within the function, they remain changed in the function that called it.