October 2019
Beginner to intermediate
498 pages
14h 13m
English
Throughout the previous chapters, we have used functions to implement abstraction. We have broken problems down into smaller, more manageable pieces and have implemented functions that we can call over and over again. In the previous section we pushed this idea one step further by passing functions as parameters to other functions. In this section we explore in more detail the underlying mechanics of functions and parameter passing.
Consider the function shown in LISTING 6.7, which computes the hypotenuse of a right triangle. Using the Pythagorean theorem, a2 + b2 = c2, this function needs the lengths of the two sides, called a and b, and computes and returns the length of the long side, called ...
Read now
Unlock full access