← Quiz: Storage Classes in C: all 15 questions
Quiz: Storage Classes in C · Question 4 of 15
A global variable is declared as static int hits; in log.c. What is true?
A global variable is declared as static int hits; in log.c. What is true?
- A.Other files can use it with extern
- B.Only code in log.c can use it, and it starts at 0
- C.It is created again each time a function in log.c runs
- D.It holds a garbage value until assigned
Answer & explanation
Correct answer: Only code in log.c can use it, and it starts at 0
At file level, static gives internal linkage (private to the file). Its lifetime is still the whole program, and statics start at 0.
Can you get the rest right without peeking?
Take the timed Quiz: Storage Classes in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →