1. Home
  2. Computer Science MCQs
  3. C Programming
  4. Which storage class in C keeps a local variable alive for…

Added 30 Nov -0001

Which storage class in C keeps a local variable alive for the entire program?

  1. extern
  2. register
  3. static Correct answer
  4. auto

Correct answer

C. static

18 views

MCQSEXAM

Explanation

A local variable declared static is created once and retains its value between function calls. Variables with auto and register are created afresh on every call, and extern refers to a definition kept elsewhere.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C Programming MCQs

Practise all C Programming MCQs

Similar MCQs