Ch. 6.10: Local and Global Variables Flashcards

1
Q

What is a local variable?

A

A local variable is defined inside a function and is not accessible outside the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a global variable?

A

A global variable is defined outside all functions and is accessible to all functions in its scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the lifetime of a local variable?

A

A function’s local variables exist only while the function is executing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a global constant?

A

A named constant that is available to every function in a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does shadow mean?

A

This means that the global variable or constant’s name is hidden by the name of the local or parameter variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly