
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int *getEvenNumbers(int *b, int N)
{
    int i;
    int j=0;
    int *p;
    p=(int *)malloc(N*sizeof(int));
    for(i=0;i<N;i++)
    {
        if (b[i]%2==0)
        {
            p[j]=b[i];
            j++;
        }

    }
    return p;

}

int main()
{
    int *a;
    int *h;
    int N, i;

    printf("please enter the number of integers wanted\n");
    scanf("%d", &N);
    a=(int *)malloc(N*sizeof(int));
    srand(time(NULL));
    printf("the random numbers are:\n");
    for (i=0; i<N; i++)
    {
        a[i]=rand()%10;
        printf("%d\n", a[i]);
    }
    printf("the even numbers from this list are:\n");

    h=getEvenNumbers(a,N);
    for(i=0;i<N;i++)
    {
        if(h[i]!=0)
            printf("%d\n",h[i]);
    }

return 0;
}
