0

Hello, i can not quite figure out how to write a function to take numbers from an array and sort so it displays even numbers first and then odd numbers.

the output should look like this:

Original: 9 8 7 6 5 4 3 2 1

Reversed: 1 2 3 4 5 6 7 8 9

Original: 9 8 7 6 5 4 3 2 1

Even: 2 4 6 8 5 3 7 1 9

All the other functions work it is just the evenOdd function that does not.

Here is what i have written for the function:

```
void evenOdd(int *arr[])
{
int arr[N], i;
for(i = 0; i < N; ++i)
{
if (arr[N] %2 == 0)
*arr;
}
}
```

Here is the whole program if anyone wants to compile it to check:

```
#include <stdio.h>
#include <stdlib.h>
#define N 9
void revArray(int arr[])
{
int temp[N];
int i;
for(i = 0; i < N; ++i)
{
temp[i] = arr[N - 1 -i];
}
for(i = 0; i < N; ++i)
{
arr[i] =temp[i];
}
}
int *revElement(int arr[])
{
static int idx = N;
idx = --idx;
return arr + idx;
}
void evenOdd(int *arr[])
{
int arr[N], i;
for(i = 0; i < N; ++i)
{
if (arr[N] %2 == 0)
*arr;
}
}
/* MAIN */
int main(int argc, char **argv)
{
/* Load the array with numbers */
int a[N];
int idx;
int *p = a;
/* p points to a[0]
by storing the address &a[0]
*/
/*
while(p < a + N) *p++ = a + N - p; /*\
using p, fill up the array one
index at a time
*/
while (p < a + N)
{
*p = a + N - p;
p = p + 1;
}
printf("Original: ");
p = a; while(p < a + N) printf("%2d ",*p++);
/* Part A: Reverse the array */
/* AS IN reverse the contents of the original array a */
revArray(a);
printf("\nReversed: ");
p = a; while(p < a + N) printf("%2d ",*p++);
printf("\n");
/* Part B: Return elements in reverse order */
/* AS IN NOT to modify the contents of the array
which are in order
1 2 3 4 5 6 7 8 9
but to print the contents of this array
from the last index to the first one.
HINT: this would be a good function to
use static variable(s) in.
*/
printf("Original: ");
for (idx = 0; idx < N; idx++) {
printf("%2d ",*revElement(a));
}
printf("\n");
evenOdd(a);
p = a; while(p < a + N) printf("%2d ",*p++);
printf("\n");
system("pause");
exit(0);
}
```

Any help would be much appreciated, thank you.