LearnFrenzy
Sign in Take a free test

C Variables · Variables MCQ · Question 5

Lifetime of a static local variable in C Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links