Multiple choice

int var1; If a variable has been declared with file scope, as above, can it safely be accessed globally from another file?

  1. Yes; it can be referenced through the register specifier.

  2. No; it would need to have been initially declared as a static variable.

  3. No; it would need to have been initially declared using the global keyword.

  4. Yes; it can be referenced through the publish specifier.

  5. Yes; it can be referenced through the extern specifier.

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

A variable declared at file scope without static has external linkage by default. To reference it from another file, it must be declared with the extern keyword.