5. You want a variable in C that keeps its value between function calls but is only accessible inside that function. Which storage class should you use?
hard
A. static
B. extern
C. auto
D. register
Solution
Step 1: Understand variable lifetime and scope requirements
The variable must keep its value between calls (persistent lifetime) and be local to the function (limited scope).
Step 2: Match storage classes to requirements
'static' inside a function keeps the variable value between calls and restricts scope to that function.
Final Answer:
static -> Option A
Quick Check:
Static inside function = persistent and local [OK]
Hint: Use static for persistent local variables [OK]
Common Mistakes:
Using auto which resets each call
Using extern which is global
Using register which is for CPU registers
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.