LearnFrenzy
Sign in Take a free test

Functions and Default Arguments · Functions MCQ · Question 11

Lifetime of a static local variable Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

How long does a static local variable live?

  • A Until the function returns
  • B From its first initialization until the program ends Correct
  • C Only during the first call
  • D Until the next call
Correct Answer: Option B

It is initialized once and keeps its value across calls, but its name is visible only inside 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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links