Thanks oogabooga...seems like this code might be the one he asked for
I modified my function to use the return value, which got rid of one of the static variables and shortened the code a little. Now that's probably what your teacher was looking for.
The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss