Study for the Internet of Things (IOT102) Test. Access comprehensive flashcards and multiple choice questions, each with hints and explanations. Get prepared for your exam!

Multiple Choice

Which describes global variables in programming languages?

Global variables live in the program’s global scope, meaning they’re defined outside any function and can be read or changed from anywhere in the program. Because they belong to the global scope and persist for the whole run, they’re usable anywhere in the program, which is why that option is the best description. In contrast, variables that are only inside a function are local to that function, and a local scope keeps variables confined to that block. Saying a global isn’t accessible by other modules contradicts the idea of globals, though some languages require explicit sharing or exporting of globals across modules.

Global variables live in the program’s global scope, meaning they’re defined outside any function and can be read or changed from anywhere in the program. Because they belong to the global scope and persist for the whole run, they’re usable anywhere in the program, which is why that option is the best description. In contrast, variables that are only inside a function are local to that function, and a local scope keeps variables confined to that block. Saying a global isn’t accessible by other modules contradicts the idea of globals, though some languages require explicit sharing or exporting of globals across modules.