A function is executed when it is
called
What is the output of the following program?
int getValue(int);
int main()
{ int x = 2;
cout << getValue(x) << endl;
return 0; }
int getValue(int num)
{ return num + 5;}
7
Look at the following function prototype: int myFunction(double, double, double);
How many parameter variables does this function have?
3
Local variables are initialized to zero by default
False
You must supply an argument with a function call
False
Here is the header for a function named computeValue: void computeValue(int value)
Which of the following is a valid call to the function?
computeValue(10);
A function's return data type must be the same as the function's parameter(s)
False
Look at the following function prototype: int myFunction(double);
What is the data type of the funtion's return value?
int
Look at the following function prototype: int myFunction(double);
What is the data type of the funtion's parameter variable?
double
A ___________ variable is declared outside all functions
global
If a function is called more than once in a program, the values stored in the function's local variables do not _________ between function calls
persist
EXIT_FAILURE and __________ are named constants that may be used to indicate success or failure when the exit() function is called
EXIT_SUCCESS
A local variable and a global variable may not have the same name within the same program
False
When used as parameters, these types of variables allow a function to access the original arguments
reference
Global variables are initialized to zero or NULL by default.
True
A function can have zero to many parameters, and it can return this many values
only one
Which of the following statements about global variables is true?
A global variable can have the same name as a variable that is declared locally within a function.
A function __________ eliminates the need to place a function definition before all calls to the function
prototype
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function
call
This function causes a program to terminate, regardless of which function or control mechanism is executing
exit()
A function __________ contains the statements that make up the function
definition
You may use the exit() function to terminate a program, regardless of which control mechanism is executing
True
One reason for using functions is to break programs into manageable units, or modules
True
In a function header, you must provide
1. data type(s) of the parameters
2. data type of the return value
3. The name of function
4. Names of parameter variables
A parameter is a variable that is declared inside the parentheses of a function definition and it acts as a placeholder
True