WRITE A FUNCTION DEFINITION FOR A FUNCTION ISDIGIT THAT TAKES ONE...

14. Write a function definition for a function isDigit that takes one argument of type charand returns a bool value. The function returns true if the argument is a decimal digit; oth-erwise, it returns false.

DEFINING

void

FUNCTIONS

In C++ a

void

function is defined in a way similar to that of functions that return a

value. For example, the following is a

void

function that outputs the result of a calcula-

tion that converts a temperature expressed in degrees Fahrenheit to a temperature

expressed in degrees Celsius. The actual calculation would be done elsewhere in the

program. This

void

function implements only the subtask for outputting the results of

the calculation.

void showResults(double fDegrees, double cDegrees){ cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); cout << fDegrees << " degrees Fahrenheit is equivalent to\n" << cDegrees << " degrees Celsius.\n";}

As the above function definition illustrates, there are only two differences between

a function definition for a

void

function and for a function that returns a value. One

void

difference is that we use the keyword

void

where we would normally specify the type

function definition

of the value to be returned. This tells the compiler that this function will not return

any value. The name

void

is used as a way of saying “no value is returned by this func-

tion.” The second difference is that a

void

function definition does not require a

return

statement. The function execution ends when the last statement in the func-

tion body is executed.

A

void

function call is an executable statement. For example, the above function

showResults

might be called as follows:

callshowResults(32.5, 0.3);

If the above statement were executed in a program, it would cause the following to

appear on the screen: