Grandfather process should go through numbers from 3 to N-1. Send each number through pipe(filedes) to Father.
Father should check the content of the pipe and compute something for each number in there. If the result is positive, create children to further compute it. Children should write their results into pipe(filedes1) to grandfather. Grandfather should check the pipe before communicating with Father.

In a nutshell: 

```
Grandfather - sends data to Father
Father sends data to Children
Children send data to Grandfather

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>

#define N 20

int pid[N],child_no=0;

int prim(int m)
{
    int i;

    for (i=2; i<=m/2; i++)
        if (m%i==0)
            return 0;

    return 1; //prim
}

int check_multiples(int i, int filedes11);

int main()
{
    int filedes1[2], //grandpa->father
        filedes2[2], //father->child
        filedes3[2]; //child->grandpa
        //pid[N],,i=0

    if (pipe(filedes1)<0)
    {
        perror("pipe1");
        exit(EXIT_FAILURE);
    }
    if (pipe(filedes2)<0)
    {
        perror("pipe2");
        exit(EXIT_FAILURE);
    }
    if (pipe(filedes3)<0)
    {
        perror("pipe3");
        exit(EXIT_FAILURE);
    }

    if ((pid[child_no]=fork())<0)
    {
        perror("fork");
        exit(EXIT_FAILURE);
    }
    else
        if (pid[child_no]==0) //father
        {
            int m,v[N],j=0;

            close(filedes1[1]);

            while (read(filedes1[0],&m,sizeof(m)))
            {
                if (prim(m))
                    v[j]=m;

                child_no++;

                if ((pid[child_no]=fork())<0)
                {
                    perror("fork");
                    exit(EXIT_FAILURE);
                }
                else
                    if (pid[child_no]==0)
                    {
                        int k;

                        close(filedes3[0]);
                        for (k=2; k*m<=N; k++)
                        {
                            write(filedes3[1],&(int){k*m},sizeof(k*m));
                            write(filedes3[1], &(int){0}, sizeof(int));
                            exit(0);
                        }
                    }
            }

            int k;
            printf("Prime numbers between 3 and N-1 are: ");
            for (k=0; k<N; k++)
                printf("%d ",v[k]);
            printf("\n");
        }
        else  //grandfather
        {
            int i,m,check=0;

            close(filedes3[1]);
            close(filedes1[0]);
            for (i=3; i<N; i++)
            {
                printf("Checking %d...\n",i);

                if (i!=3)
                {
                    while (read(filedes3[0],&m,sizeof(m))!=0)
                    {
                        printf("%d\n",&m);
                        if (m==0)
                            break;
                        if (i==m)
                        {
                            check=1;
                            break;
                        }
                    }
                }
                printf("Finished checking %d.\n",i);
                if (check==0)
                    write(filedes1[1],&i,sizeof(i));
            }

        }

    return 0;
}

```
['https://Stackoverflow.com/questions/24854623', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2636820/']
Just try with:

```
list($month, $day, $year) = explode('/', $birthdate);

```
If your format is fixed and you don't need to validate the date, you can directly use `substr`:

```
echo substr($birthdate,0,2); // month
echo substr($birthdate,3,2); // day
echo substr($birthdate,6,4); // year

```