Let us first expand the expression given in the main function;
sum+=g(f(n)) can be written as sum=sum+g(f(n))
now, coming to the for loops, it is run two times.
when $n=1,1<3:T$,it is called as $0+g(f(1))$.
when $f(1)$ is called it return $g(2)$ which is go to function g(n) where it is executed $10+2$ and return $12$ to main fuction.again
sum=0+g(12), now we call one more time $g(n)$ this time it return $10+12=22$.Therefore final value of the sum after the first iteration is $22.$
now increment $n++$ gives $n=2,2<3:T$, loop will run one more time as $sum=22+g(f(2))$
when $f(2)$ is called it return g(4) which go to function $g(4)$ and it return as $10+4=14$ to main fuciton.
so $sum=22+g(14)$, now $g(14)$ will return again $10+14=24$. so the final value of the sum is $22+24=46$
so the output of the given program is $46.$