function exercises

EE Centric

If you are an EE type, the resistor quiz page and solutions are good exercise.  Another EE exercise is to print out square wave.  Square wave has frequency and duty cycle.  How do you design your function such that it handles different frequency and duty cycle?  A KISS example is here:

Preparation for Object Design

Write routines for adding, subtracting, multiply, divide two rational numbers.

A Real Problem Solving

Suppose you want to print a monthly calendar.  A simple exercise to start is to print just one month.  Let's say you get two parameters to your function, which month and the day of the week the month starts.

monthlyPrint (int month, int dayofweek)

In the main program, you will supply parameters and call the monthlyPrint function.

If that's not enough exercise for you, try to print the whole year.  The routine could be

yearlyPrint(int year)

Since the day of the week can be derived directly from year, you do not need the other parameter.  At most, you just need a fixed date, e,g. Jan 1, 2000 is a Saturday.