LIST THE SIMILARITIES AND DIFFERENCES BETWEEN HOW YOU INVOKE (CALL...

11. List the similarities and differences between how you invoke (call) a predefined (that is, library) function and a user-defined function.

FUNCTIONS THAT RETURN A BOOLEAN VALUE

The returned type for a function can be the type

bool. A call to such a function returns

one of the values

true

or

false

and can be used anywhere that a Boolean expression is

allowed. For example, it can be used in a Boolean expression to control an

if-else

statement or to control a loop statement. This can often make a program easier to read.

By means of a function declaration, you can associate a complex Boolean expression

with a meaningful name. For example, the statement

if (((rate >= 10) && (rate < 20)) || (rate == 0)){...}

can be made to read

if (appropriate(rate))

provided that the following function has been defined:

bool appropriate(int rate) return (((rate >= 10) && (rate < 20)) || (rate == 0));

Self-Test Exercises