Sometimes you will want to create a function which accepts more than one parameter. This may be because you want to combine several values to create a single result, or it may be because the task the function is going to perform needs several items to make it work:

On the right you can see the declaration of a function called flashLight. This accepts two integers. The first tells the function how many flashes, and the second sets the speed at which the flashing takes place. We can then call the function to make different flash patterns.

You give the parameters in a comma separated list. First you give the type of the parameter then you give the name by which it will be referred to within the function body. Note that you must make sure that when you actually call the function you provide the correct number and type of parameters:

/* flash the light  */
flashLight ( 25 ) ;

The above code is doomed to failure because we have not provided a speed value (or perhaps we missed off the count). Either way we must rely on the compiler detecting that we have done something stupid and then telling is. Unfortunately not all versions of C are clever enough to notice that we have not used a function correctly. In the above case our program would do something stupid (but we don't actually know what that is). The correct way to use the function would be as follows:

/*flash the light slowly 10 times*/
flashLight ( 10, 100 ) ;

Note also that I have made a rather bad design decision, in that I called the speed value speed. This is somewhat confusing for another programmer. Do I mean that the bigger the value, the faster the light will flash? Or do I mean that speed gives a delay value which means that the bigger the value, the slower the light will flash.

You should be careful when choosing your variable names so that they are not ambiguous like this. I'd be inclined to call the parameter delay, which should imply that the bigger the value the longer the delay. However, I would also add comments to the code when I declared the function so that users of it were left in no doubt as to how to use it. It is considerations like this which mark the difference between good programmers and great programmers!