Home »
MCQs »
C++ MCQs
What is the lifetime of a static variable declared in a user-defined function?
108. What is the lifetime of a static variable declared in a user-defined function?
- Within the function only
- Within the main function only
- Whole program
- None of the above
Answer: C) Whole program
Explanation:
The lifetime of a static variable is in the whole program. But its scope is within the function only.