In the main variable i ,x,y are declared and x=5 ,y=10
now for i=1,first iteration will be there,
i=1
y+=f(x)+g(x)=>y=y+(f(5)+g(5)) ( for x=5 )
now f(5) will be called ,value 5 is copied to the local variable x inside the function f (x),now x=5 and y is a local variable defined inside the function f so scope of x and y will be limited to function f (x) .
here y=g(x)=>y=g(5) ,now g(5) will be called ,
value 5 is copied to local variable x inside the function g(x) and here y is static local variable so its scope is local but its lifetime is till the program ending.Here y=5 now y=y+7 is executed so value of y becomes 12,then x+y =17 will be returned.
so y=g(5)=17, now x+y from g(x) will be returned means 22 will be returned.
now g(5) will be called ,in 5 is copied to x,means x=5 and y is static variable and its value is 12 now ,after executing y=y+7 value of y becomes 19 ,now x+y will be returned means 24 .
finally for first iteration y=10+22+24=56.
now i will be incremented and becomes i=2 here x=5 and y=56
y+=f(x)+g(x)=>y=y+(f(5)+g(5)) ( for x=5 )
now f(5) will be called ,value 5 is copied to the local variable x inside the function f (x),now x=5 and y is a local variable defined inside the function f so scope of x and y will be limited to function f (x) .
here y=g(x)=>y=g(5) ,now g(5) will be called ,
value 5 is copied to local variable x inside the function g(x) and here y is static local variable so its scope is local but its lifetime is till the program ending.Here y=19 (previous value) now y=y+7 is executed so value of y becomes 26,then x+y =31 will be returned.
so y=g(5)=31, now x+y from g(x) will be returned means 36 will be returned.
now g(5) will be called ,in 5 is copied to x,means x=5 and y is static variable and its value is 26 now ,after executing y=y+7 value of y becomes 33 ,now x+y will be returned means 38
finally for first iteration y=56+36+38=130
now i will be incremented and becomes 3 ,now condition is false so will come out of the loop
finally ,y=56 for i=1 and y=130 for i=2
.