modular programming Flashcards
decomposition
break down large problem into smaller problems.
break down a large program into sub- procedures (modules)
procedures
do not return a value
functions
do return a value
advantages of decomposition/ modular programming
- each small prob is easier to solve
- can share programming among a team
- program more readable
- modules are re- usable
how modules are held in memory
a new area of memory opens while the module runs and closes when it finishes running
local variables
can only be used inside the module
lost when the module closes
global variables
can be used anywhere in the program
changes to them are permenant
parameters
values passed from main prog to module
are used like variables in the module
returned values
when function stops a single value can be returned to the main program.
it must be captured or it will be lost.
parameter passed by value
module gets a copy of the value, and it does not change the values in the main program
parameter passed by reference
the module gets access to the original variable’s memory location. therefore it can change values used in the main program without using return.