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_park
that declares 4 variables. Two global integer variables callednum_gnus
andnum_gnats
, and two local floating point variables within the functionmain
, calledavg_gnu_mass
, andavg_gnat_mass
. Then add another function calledcalculate_park_biomass
, and passavg_gnu_mass
andavg_gnat_mass
to it. How many different storage spaces are used when this program runs? (Hint: areavg_gnu_mass
andavg_gnat_mass
and their copies the same?)