Font size
WorksheetsFunctions
Total questions: 20
Worksheet time: 20mins
Select the correction function prototype from the following options. Select 2 correct answers.
void first();
void first()
void myFunction():
void myFunction();
Fill in the blank: Function prototypes are also known as ____
function declarations
function assignments
function operations
function definitions
Select a correct function call.
myValue(int 7);
myValue(7);
myValue(double, 7000);
myValue (4.2)
Select the correct syntax for a function header that contains a parameter list.
void showTotal (int num1, int num2, num3)
void showTotal (int num1, num2, num3)
void showTotal (int num1, int num2, int num3)
void showTotal (num1, num2, num3)
What type of statement will force the function to end immediately?
end;
terminate;
quit;
return;
Fill in the blank:
Data can be returned from a function, back to the statement that called it, which is known as ____.
data-passing function
value-returning function
value-assignment function
data-populating function
Which of the following function will return a value?
int sum (int val1, int val2)
{
return val1+val2;
}
void sum (int val1, int val2)
{
return sum;
}
void sum (int val1, int val2)
{
return val1+val2;
}
int sum (val1, val2)
{
return sum;
}
What value is returned in the following code snippet?
bool isValid(int number)
{
bool status;
if (number >= 1 && number <= 100)
status = true;
else
status = false;
return status;
}
number between 1 to 100
valid or invalid
"status"
true or false
What is the lifetime of the local variable?
as long as the computer is on
while the function is executing
forever
until the function is called
By default, global variable is initialized with what value?
255
1
0
not initialized to any value by default
Fill in the blank:
A named constant that is available to every function in a program is known as ____.
global variable
local variable
global constant
local constant
Select the correct statement.
two local variables with the same name can exist in the same function.
a parameter variable and a local variable can have the same name in the same function.
a local variable variable can have the same name as a global variable.
the name of the local or parameter variable can never be the same as the name of the global constant.
All static local variables are initialized to what by default?
0
1
256
255
Identify the default argument in prototype:
void showArea(double = 20.0, double = 10.0);
20.0 and 10.0
double and double
showArea
there is no default argument
Select the correct prototype
void calcPay(double hours = 40.0, int empNum, double payRate);
void calcPay(int empNum, double hours = 40.0, double payRate);
void calcPay(int empNum, double payRate, double hours = 40.0);
void calcPay(int empNum = 1, double payRate = 22, double hours);
Which of the following option represents a reference variable myVar?
void doubleNum (int myVar);
void doubleNum (int %myVar)
void doubleNum (int &myVar)
void doubleNum (int, myVar)
Fill in the blank:
When you assign the same name to multiple functions, but use different parameter lists, this is known as ______.
Overloading functions
Replicating functions
Passing functions
Alternating functions
What is the signature of the function header:
double square(double number)?
square (double number)
double (double number)
square (double)
square (number)
What type of function causes a program to terminate, regardless of which function or control mechanism is executing?
terminate()
end()
quit()
exit()
What type of program tests a function by simply calling it and passes test data if the function accepts arguments?
stub
driver
tester
pass
