Let’s look at i = 1. When i=1, if condition executed one time. Let's understand what happens when $fork()||fork()$ executes.
first $fork()$ creates two children (i.e. one parent and one child). Parent gets the address of its children (i.e. process id of its children) and the child gets $0$.
Now, for each node, two children are created by the 2nd $fork()$.
Among them, first three children get executed (i.e. for the last child $if(0||0)$ never gets executed).
The below diagram shows the execution for $i=1$
$\therefore$ total number of “Hi” printed for i=1 is $3$.
Now, for i=2, each of the leaf nodes will have the same subtree as its parent (i.e. each produces 3 “Hi” as output).
$\therefore$ total number of “Hi” printed for i=2 is $3*4=12$.
For, i=3, total “Hi” will be $12*4=48$
Code