Create organized sections of executable code that execute in
well-understood ways and can be reused
Subroutine
Performs operations for the caller while the caller waits
Arguments, or actual parameters, are passed to subroutines
and mapped to formal parameters from the subroutine
definition
Subroutines that can return values can be called
functions
Call Stack
Memory space for functions to use to store local variables, return
addresses, and other data
Function calls push a new frame to the stack
Returns pop their frame when they are finished with it
DrawSquare Example
void DrawSquare(int x,int y,int size){/* Draw a square using 4 lines */ DrawLine(x, y, x, y + size); DrawLine(x + size, y, x + size, y + size); DrawLine(x, y, x + size, y); DrawLine(x, y + size, x + size, y + size);}