Question 5
Back to Exercise
How long does a static variable declared inside a function exist?
- A Until the function returns
- B For the whole run of the program Correct
- C Until the next call
- D Only during the first call
Correct Answer: Option B
A static local has static storage duration: it is created and initialised once, before the program starts, and keeps its value between calls. Only its name is limited to the function.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!