Forking

When I compile this C programme I get different outputs each time I run it
Please explain to me whats happening in the code if you can give me a detailed explanation with the schedular functionality it will help a lot. Because I am stuck with this.



   #include <stdio.h>

   main(){

            int i = 0;

            printf("I am the parent\n");

            for( i =0 ; i < 3 ; i++ )

                 if( ! fork() )

                      printf("I am a child  %d  \n",i);

}

You are breaking the rules for posting on this site with this post. You have already posted the same question here.
Check rule 4:
(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.

The OP is breaking the rules but there is an additional question in this thread "with the schedular functionality," which was the answer from the other thread.

This is a duplicate thread which, as other have noted, is against the rules. Post any followup questions in the original thread. I will close this thread.