ProgrammingEasyWipro · Capgemini pattern

Which storage class makes a local variable keep its value between calls to the function?

  1. A. auto
  2. B. static
  3. C. extern
  4. D. register

Correct answer: B. static

A static local is created once, initialised once and lives for the whole run, so its value survives between calls. auto and register locals are recreated on every call; extern only declares a variable defined elsewhere.

More C Programming questions

Exams that ask this topic