Variables & Scope MCQs

12 MCQs  — Fundamental Programming MCQs  (Page 1 of 2)

Practice Variables & Scope MCQs with correct answers and explanations. These questions are from the Fundamental Programming MCQs section.

What is the value of an uninitialized local (automatic) int variable in C++?
Indeterminate (garbage); reading it is undefined behavior
INT_MIN
Always -1
Always 0
What are the scope and lifetime of a static local variable declared inside a C++ function?
Block scope and a lifetime of one function call
Block scope, but a lifetime equal to the whole program run
Global scope and program lifetime
File scope and a lifetime of one function call