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

Discussion

What is the scope of an external variable?

  • A.Whole source file in which it is defined
  • B.From the point of declaration to the end of the file in which it is defined
  • C.Any source file in a program
  • D.From the point of declaration to the end of the file being compiled

Answer: D

Correct answer: From the point of declaration to the end of the file being compiled

Scope runs from the point of declaration to the end of the file - a variable declared at the bottom of a file is not visible to functions above it. Being reachable from other files is a matter of linkage, which is a different property; an extern declaration in the other file is what brings it into scope there.

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

Post your comment

Please log in or register to post a comment.