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?

  1. A.

    Global Scope; it can be accessed anywhere in the entire program.

  2. B.

    Local Scope; it can only be accessed within that specific function.

  3. C.

    Universal Scope; it is saved to the hard drive for future use.

  4. 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.

Explore the full course: Rssb Senior Computer Instructor