Functions and recursion: Difference between revisions

wikademia>Steaxauce
Line 162: Line 162:


===Scope===
===Scope===
Scope refers to the level of access an object has. A function can access only global variables and those that are passed to it through arguments. Also, any variable declared inside a function are only available to that function.
Scope refers to the level of access an object has. A function can access only global variables and those that are passed to it through arguments. Also, any variables declared inside a function are only available to that function.
For example, an integer declared in <tt>main<tt> will not be available to any other function unless it is passed as an argument. Vis versa, an integer declared in a function will not be available to the <tt>main<tt> function.
For example, an integer declared in <tt>main<tt> will not be available to any other function unless it is passed as an argument. Vis versa, an integer declared in a function will not be available to the <tt>main<tt> function.