Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nate Brunelle Today: Functions again, Scope

Similar presentations


Presentation on theme: "Nate Brunelle Today: Functions again, Scope"— Presentation transcript:

1 Nate Brunelle Today: Functions again, Scope
CS1110 Nate Brunelle Today: Functions again, Scope

2 Questions?

3 Last Time Functions

4 Visualizing Programs

5 Scope Scope- The area where a variable has meaning
Usually: variable is in scope when it is created onward. Functions: variable is in scope only in the function in which it is defined

6 What happens when you invoke a function?
Create memory for the function Copy argument values into parameter names Do what the function says Know what to return Remove the memory for the function

7 Which variable v is in scope?
If the variable v is available in the local scope, use that one If the variable v is not available in the local scope, use the variable v available in the global scope If a function ever will have the local variable v, you can only use that variable v

8 Global variables Allow you to have something “remembered” from one run of a function to another.


Download ppt "Nate Brunelle Today: Functions again, Scope"

Similar presentations


Ads by Google