Practice mode C Language

In C, what value does a static local variable have if it is declared without an initialiser?

Correct answer C. Zero

Explanation

Objects with static storage duration, including static locals and file-scope variables, are initialised before program start-up; if no initialiser is given they are set to zero (null for pointers). Ordinary automatic locals are different: without an initialiser their value is indeterminate, and reading it is a bug. A static local is initialised only once, not on every call.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.