How does the 'extern' keyword affect the scope and lifetime of a variable in C?

  • It doesn't affect the scope or lifetime of a variable.
  • It extends the scope and lifetime of a variable.
  • It extends the scope but reduces the lifetime of a variable.
  • It reduces the scope but extends the lifetime of a variable.
In C, the 'extern' keyword extends the scope of a variable but reduces its lifetime. It allows a variable declared outside a function to be used within that function, but the variable's lifetime remains outside the function.
Add your answer
Loading...

Leave a comment

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