What is special about a static local variable declared inside a function?
-
A
It is stored in the caller's frame
-
B
It becomes visible in other files
-
C
It is reset on every function entry
-
D
It retains its value between calls
Correct answer
Correct answer
D. It retains its value between calls
16 views
Explanation
A static local has static storage duration, so its value persists across calls although its name stays block-scoped.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ