A function that has a return value produces a value that you can assign to a variable or use in some other expression. For example, the standard C/C++ library includes a function called `sqrt()`

that returns the square root of a number. Suppose you want to calculate the square root of 6.25 and assign it to the variable `x`

. You can use the following statement in your program:

x = sqrt(6.25); // returns the value 2.5 and assigns it to x

The expression `sqrt(6.25)`

invokes, or *calls*, the `sqrt()`

function. The expression `sqrt(6.25)`

is termed a *function call*, the invoked function is termed the *called function*, and the function containing the function call is termed the *calling function* (see Figure 2.6).

Start Free Trial

No credit card required