Here we need to keep in mind three things :
a) The initialisation statement of for loop runs only once while the other two runs till loop fails
b) Every function has its static area..So once a static variable is initialised in a function ; it is not re-initialised i.e. in next function call the value is taken from previous invocation of that function.
c) Post - increment/decrement operator uses the value then increments / decrements the concerned variable.
So here ,
Initial value of num = 16
So using initialisation step of for loop which uses a fun() call , it will return 16 as value since in "num--" first num value is used n then decremented.
Now num value = 15 after initialisation..Now when condition part comes , it just checks the return value of fun which will be 15 and then num is decremented to 14. Now we come to body of loop which again uses fun() call in printf() function..Here fun() will return 14 which in and then decrement it to 13..As the return value here was 14 , it is printed by printf().
Now third statement of for loop will work which uses fun() as well..It will return 13 and decrement num to 12..
Having iterated for the first time , now initialisation will not be executed as it is executed only in 1st iteration..Hence condition part evaluates num to 12 and decrements it to 11 according to function definition of fun()..
Now in the body of the loop , fun() is used again which returns value of 11 and hence 11 is printed as fun() is used as an argument for printf() function.So in the second iteration we get the printed value as "11"..
Likewise in the subsequent iterations : 8 , 5 and 2 are printed .
So when 2 is printed after that in the third statement of for loop num value is 1 which is returned by the third statement of the for loop and then num becomes 0..Then in the next loop 0 is returned and num becomes -1..But as return value is 0 hence condition evaluates to false and the loop terminates.
Hence the output sequence is : 14 , 11 , 8 , 5 , 2