the last print statement to be executed is in the main(). Since every time foo() is called, we are doing pass by value, the value stored in variable sum is local to foo() function calls.
So when control returns to main(), the value of sum will be 0. (as initialized in main()'s body). That eliminates (a) & (c).
Recursive calls(values stored in stack -> LIFO) on foo(), when returned is printing k values in the reverse order : 2->0->4->>8
Hence, answer : (d)