Variable Scope Flashcards

OCR GCSE J277 Computer Science specification

Variable scope

The part of a program where a variable can be accessed or modified.

1 / 10

Ready to master these flashcards?

Sign in to study with spaced repetition and track your progress.

Sign In to Track Progress

Terms in this set (10)

1

Variable scope

The part of a program where a variable can be accessed or modified.

2

Local variable

A variable that is declared within a subprogram and can only be accessed within that subprogram.

3

Global variable

A variable that is declared outside of subprograms and can be accessed throughout the entire program.

4

Advantages of local variables

They help prevent unintended changes to data and make subprograms easier to debug and maintain.

5

Disadvantages of global variables

They can lead to unintended changes to data and make debugging more difficult.

6

Use of global variables

Global variables are useful for storing data that needs to be accessed by multiple parts of a program.

7

Use of local variables

Local variables are useful for temporary data that is only needed within a specific subprogram.

8

Scope of a local variable

Limited to the subprogram or block of code where it is declared.

9

Scope of a global variable

Accessible throughout the entire program, including all subprograms.

10

Best practice for variable scope

Use local variables whenever possible to reduce the risk of errors and improve program maintainability.

Genie

Want to Learn More?

Get personalised lessons, quizzes, and instant feedback from your AI tutor.

Start Learning