300 views
1 votes
1 votes

1 Answer

1 votes
1 votes
B is correct.

Concept: Auto variable will be initialized and a new copy will be created everytime we call main. While static variable is initialized only once, the value is retained across a function call.

I. auto variable x is initialized each time it is called after a new memory is allocated to it. So the --x will never reach 0 and there will be infinite nested function call till stack overflows.

II. A static variable is initialized only once and memory is allocated only once. So there will be only one copy of x on which all --x operations are performed. Function call will continue till x==0 (base condition) is reached. Now x value is 0. So all the printf statements after main() will print 0.

No related questions found