Machine-translated by Google. Questions are authored in English.
Top

Discussion

An external variable

  • A.is globally accessible by all functions
  • B.has a declaration
  • C.will be initialized to 0 if not initialized
  • D.all of these

Answer: D

Correct answer: all of these

All three statements describe an external variable. It has file scope and external linkage, so it is accessible from every function in the program, including functions in other translation units that declare it with extern.

It has a declaration, and it has static storage duration, so if no initialiser is given it is zero-initialised before the program starts rather than holding a garbage value. That last property distinguishes it sharply from an automatic variable, whose uninitialised value is indeterminate.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.