Similar questions 5 more →
Scope, Lifetime & Storage Classes


Answer & solution
Official answer: D
Under the same intended valid-declarations assumptions as the preceding common-data question, changing main-local a to auto does not change its lifetime within this single invocation of main: it still becomes 2. Changing prtFun-local a to register gives it automatic storage duration, not persistent storage; each call initializes it to 2. Each call also initializes local b=1, increments b to 2, adds 2 to a, and prints (4, 2). Finally main prints its a=2 and the zero-initialized global b=0. The three output pairs are (4, 2), (4, 2), (2, 0), option D. register does not guarantee physical register allocation.
Check: Storage-class changes affect persistence, not lexical scope. Both modified declarations still shadow the same globals. The register local is recreated on every invocation, so it cannot retain the first call’s value 4 when the second call starts.