When a child process gets created, process id of the child process which is a +ve value returns to Parent process, 0 to child process, and -ve value to parent when child cretaion fails.
When Parent process executes this program:
condition will be FALSE for parent, as fork() will be replaced with +ve process id value.
hence nothing will be printed by parent process.
But newly created child process will print GATE2018 as 'if' evaluates to true for it.
Next Fork() will be executed by Parent and first child process both. here TWO new processes will be created, one by parent and second by the first child. So first child of parent will get its sibling and first child will get its own child too.
GATE2018 will be printed twice, once by new child and second by child of child
So, in total GATE2018 will be printed thrice!