Similar questions 5 more →
Scope, Lifetime & Storage Classes

Answer & solution
Official answer: B
Step through it (29 steps)
1. A static local variable is initialized once and keeps its value between calls. Post-decrement returns the old num and then reduces the stored value by one.
2. A for loop evaluates its initializer once, then repeatedly evaluates condition, body, and increment in that order. Calls in the initializer and increment still change num even though their returned values are discarded.
3. The initializer returns 7 and leaves num=6. The first condition returns 6, which is true, and leaves num=5. The body returns and prints 5, leaving num=4. The increment returns 4 and leaves num=3.
4. The second condition returns 3, so the body prints 2 and leaves num=1. The increment returns 1 and leaves num=0. The next condition returns 0, which is false, so there is no third body execution.
5. Only body calls print. No space or newline separates the two digits, so the displayed output is 52, option B. In particular, the zero used to stop the loop is never printed.