Jan 9, 2002

Reading assignment:
  Deitel and Deitel Chapter 3 and Chapter 4.1-4.4
        -OR-
  Wang, Chapter 1.2, 1.12, 1.15, 3.4, 3.6-3.8

Functions
  - The purpose of a function is to separate out a well-defined task of
    manageable size
  - Putting code in functions facilitates code reusability and program clarity
  - The name should reflect the task
  - A function can have parameters - "input values"
    For example, foo_function(int num_1, int num_2, char c)
    If there are no parameters, then the parentheses will be empty
    as in foo_function() 
  - A function can have default parameters - if a default value is specified 
    then the caller may supply it optionally, or the default value is
    used.  Defaults are typically supplied in the prototype.  Note that
    default variables must go at the end of the parameter list.
  - If a parameter is passed by value, then a copy of that value is
    given to the function - the caller's value is safe and the function
    has receives the value stored in a new location - the function can
    modify it.
  - A function can return values - "output values"
    If there are no return values, declare the function "void"
    If there is one return value, declare the function to return
    a variable of this type
    If there is more than one return value, then return this value
    with a reference parameter or pointer parameter
  - If a function has a reference parameter, then that function has access
    to the caller's copy of that variable - beware!
  - There are advantages to call by value and advantages to call-by-reference
  - A function's name shows up in 3 places - in a prototype (the declaration),
    in the definition of the function itself, and when the function is called.
    The syntax for each of these is of course different.
  - The prototype looks like the header line of the function, with no
    variables (unless you want to put them in for clarity)
  - A function may call itself (recursion)
  - Functions may be "overloaded" - this means that several versions of
    the function exist with different parameter list.  Depending on
    what types of parameters the user supplies, the correct version will
    be called.
  - Some important library functions - if you #include <cmath>, you get
    access to functions such as sqrt(x), ceil(x), floor(x), log(x), sin(x),
    pow(x,y) (each of which take doubles as parameters and return double
    as the function value
  - To get random numbers, #include <cstdlib> and use the function
    rand(), which returns an unsigned int between 0 and RAND_MAX.  Use
    % to scale it to the range of values you want.
  - Call srand(time(0)); once to initialize the random number generator.
    #include <ctime> to be able to call the function "time"
   
Program from class today: diagonal.cpp