If a variable is defined inside a user-defined function, what is its “scope”,…
2026
If a variable is defined inside a user-defined function, what is its “scope”, and where can it be accessed?
- A.
Global Scope; it can be accessed anywhere in the entire program.
- B.
Local Scope; it can only be accessed within that specific function.
- C.
Universal Scope; it is saved to the hard drive for future use.
- D.
Static Scope; it can only be accessed by the main operating system.
Attempted by 320 students.
Show answer & explanation
Correct answer: B
Variables defined inside a user-defined function have local scope. This means they are accessible only within that specific function block and cannot be accessed from outside the function.