fork and sleep example in C

Just another example...
#include <sys/wait.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
 
int main(void) {
    pid_t pids[10];
    int i;
 
    for (i = 0; i < 10; i++) {
        pids[i] = fork();  
        // If the process is child, sleep...   
        if (pids[i] == 0) { 
            printf("%s %i\n","Child process started with id:", getpid());
            sleep((i+2)*2);
            _exit(0);
        }
 
    }
 
    sleep(1);
 
    pid_t x;
 
    for (i = 0; i < 10; i++) {
        printf("%s %i\n", "Waiting for:",pids[i]);
        x = waitpid(pids[i], NULL, 0);
        printf("%i %s\n", pids[i], " died...");
    }
 
    printf("%s\n", "Hello world!!");
    return 0;
}

And lets see in action:
Korays-MBP:~ koraytugay$ ./a.out 
Child process started with id: 14414
Child process started with id: 14415
Child process started with id: 14416
Child process started with id: 14417
Child process started with id: 14418
Child process started with id: 14419
Child process started with id: 14420
Child process started with id: 14421
Child process started with id: 14422
Child process started with id: 14423
Waiting for: 14414
14414  died...
Waiting for: 14415
14415  died...
Waiting for: 14416
14416  died...
Waiting for: 14417
14417  died...
Waiting for: 14418
14418  died...
Waiting for: 14419
14419  died...
Waiting for: 14420
14420  died...
Waiting for: 14421
14421  died...
Waiting for: 14422
14422  died...
Waiting for: 14423
14423  died...
14423
Hello world!!