fork( ) returns zero to newly created child process, and a positive value to the parent process and a negative value if the child creation is unsuccessful. Assuming each call is successful, it will look like below.
Let me name the different fork( ) calls as below:
t1=fork(); //A
t2=fork(); //B
if (t1!=0)
{ t3=fork(); //C
printf("Hello");
}
Notations: P for parent process, and C1,C2, C3,... for child processes.
After fork( ) - A, the value returned to parent is a positive value (i.e., the process ID of child process C1) and value returned to C1 is zero. Similarly, after fork( ) - B, child processes C2, C3 are created from parents P and C1 respectively.
The condition of if loop fails for C1, C3. Only P and C2 executes the fork( ) - C and because of which child processes C4 and C5 are created. The printf statement is executed by P, C4, C2, C5 and four times Hello will be printed.
So option (D) should be correct.
Please correct me, if I'm wrong.