Node:Questions for Chapter 6, Previous:Scope example, Up:Scope
Questions for Chapter 6
- What is a global variable?
- What is a local variable?
- Do parameters spoil functions by leaking the variables into other functions?
- Write a program
gnoahs_parkthat declares 4 variables. Two global integer variables called
num_gnats, and two local floating point variables within the function
avg_gnat_mass. Then add another function called
calculate_park_biomass, and pass
avg_gnat_massto it. How many different storage spaces are used when this program runs? (Hint: are
avg_gnat_massand their copies the same?)