5.11. Why functions?

It may not be clear why it is worth the trouble to divide a program into functions. There are several reasons:

Part of the skill of creating and using functions is to have a function properly capture an idea, so throughout the rest of the book, we will often use a function definition to explain a concept. For example, later, we will show you code that finds the smallest value in a list of values and we will present it to you as a function named min, which takes a list of values as its argument and returns the list’s smallest value.

You have attempted of activities on this page