Run 4-processes concurrently

ugp, please read our rules which state:

(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

This was a good example of what happens when you break that rule. Folks were struggling with your your 4 threads trying to figure out what you wanted. I have merged your 4 threads into one thread. I'm also a little afraid that you are violating rule 6. But you have been at this for weeks and I would think any classroom deadline has passed.

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

#define NUM_CHILDREN 4


main()
{
        pid_t children[NUM_CHILDREN];
        int i;
        setvbuf(stdout, NULL, _IONBF, 0);

        for(i=0;i<NUM_CHILDREN;i++){
                if( (children=fork()) == 0 ){
                                printf("I am child number %d and my pid is %d \n", i, getpid());
                                exit(0);
                } else {
                        sleep(2);
                        printf("I am the parent \n");
                }
        }
        exit(0);
}