Notes from Lab on 04/08/04

Commenting functions:

You should be writing comments for each function. I am looking for three things in your function comments:

For example, we've written double minOf3( double a, double b, double c) several times. A good comment for this function is
  Finds the minimum of the three numbers.
  The parameters are three doubles.
  The function returns the minimum of the three parameters.
or, more succinctly,
  This function returns the minimum of the three input parameters.
It is important to note that the function does not just find the minimum (perhaps, just printing it) but actually returns the value as well.

As another example, consider the function you wrote to print a rectangle of asterisks: void drawRectangle( int w, int h); A good comment is

Prints a rectangle of width "w" and height "h".

Sentinel Combinations:

Consider the following piece of code, similar to what you wrote for Lab 5:
#define SENTINEL -1
int main() {
    int a, b;

    while( a != SENTINEL && b != SENTINEL ) { 
What values of a and b make the loop stop? Try using a truth table with different values of a and b:

aba != Sb != Sa != S && b != S

How would you change the condition in the while loop to stop only when both a and b equal -1?