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

Discussion

Which of the following is true of external variables?

  • A.they provide a way for two way communication between functions
  • B.their scope extends from the point of definition through the remainder of the program
  • C.if they are not initialized, they will be initilised to zero
  • D.All of the above 

Answer: D

Correct answer: All of the above

All three statements describe external variables. Because any function can read and write them, they provide a channel of communication in both directions between functions without passing arguments or returning values.

Their scope runs from the point of definition to the end of the translation unit, and beyond it in files that declare them extern. Having static storage duration, they are zero-initialised if no initialiser is given. The convenience is real but so is the cost: shared mutable state is the hardest kind of code to reason about.

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

Post your comment

Please log in or register to post a comment.