Solution:
About static variables:
-Static variables are initialized only once. Subsequent calls to the function do not reinitialize them
x += f1() + f2 () + f3() + f2(); <=> x+= ((f1()+f2())+f3())+f4(); [ + operator is left to right associative]
=> f1() call: retruns 26
f2() call: returns 51 ---- here local x is static int , stored in data segment
f3() call: returns 100
f2() call: retuurn 52 ---- x is not initialized again, x = 51; x++; =>x=52
=> x+=26+51+100+52;
then "+ x"
=> x = 1+229;
=> x = 230
Order of function call is not determined:
for example, the compiler may choose the order:
f1 f2 f3 f2
or f3 f1 f2 f2
or ....
About "int f(void);":
- void => function takes no arguments
More Details about Static variables:
-A normal local Variable(without static) is strored inside the stack => when function is done executing it is removed from the stack = > the variable is also removed
-An initialized Static variable is stored in Data segment => Present in data segment till the end of program execution
-An uninitialized Static variable is stored in BSS
-Although a local static variable is not stored on the stack, its scope is still limited to the function in which it is declared. Only that function can access it by name.