Lecture 5
- Comments from Hw1.
- Something defined with
#define MAX 50
is NOT a global variable.
- IN/OUT parameters to functions. Use references only when
needed (for OUT or IN/OUT parameters). Not needed for arrays,
because they are automatically passed as references (the name of
an array is a pointer to its first element).
- Readability: do not use int * a for an array, use instead int
a[], it is more readable.
- Do not use global variables, unless REALLY necessary (and you
understand why). It is bad programming practice and the source of
many errors, if not used properly.
- Brief overview of local vs. global variables.
- Menu options: should be in a loop, so that they can be used
several times.
- Sorting
algorithms, applets from Dominique's web page. Compare
Insertion and Selection Sort. You must experiment with these
applets to get a sense of what the algorithms are doing (informal
homework).
-
Selection sort on an array of integers, done in class,
is here. Not finished. You must add the
read and print functions for integer arrays, from your hwk 1.