CSC 101 Quiz 6

25 July 2022
4.7 (114 reviews)
30 test answers

Unlock all answers in this set

Unlock answers (26)
question
The standard header file for the abs(x)function is ____. Select one: a. b. c. d.
answer
a.
question
The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____. Select one: a. 12.0 b. 13.0 c. 14.0 d. 11.0
answer
c. 14.0
question
A variable or expression listed in a call to a function is called the ____. Select one: a. formal parameter b. actual parameter c. data type d. type of the function
answer
b. actual parameter
question
A function prototype is ____. Select one: a. a definition, but not a declaration b. a declaration and a definition c. a declaration, but not a definition d. a comment line
answer
c. a declaration, but not a definition
question
Which of the following function prototypes is valid? Select one: a. int funcExp(int x, float v); b. funcExp(int x, float v){}; c. funcExp(void); d. int funcExp(x);
answer
a. int funcExp(int x, float v);
question
The statement: return 8, 10; returns the value____. Select one: a. 8 b. 10 c. 18 d. 80
answer
b. 10
question
Given the following function: int strange(int x, int y) { if (x > y) return x + y; else return x - y; } what is the output of the following statement? cout << strange(4, 5) << endl; Select one: a. -1 b. 1 c. 9 d. 20
answer
a. -1
question
If the formal parameter list of a function is empty, the parentheses after the function name are not needed. Select one: True False
answer
False
question
The execution of a return statement in a user-defined function terminates the program. Select one: True False
answer
False
question
It is not necessary to specify the names of formal parameters in a function prototype. Select one: True False
answer
True
question
When writing a function prototype, you do not have to specify the data type of each parameter. Select one: True False
answer
False
question
Assume that all variables are properly declared. The following statement in a value-returning function is legal. if (x % 2 == 0) return x; else return x + 1; Select one: True False
answer
True
question
The execution of a C++ program always begins with the function main. Select one: True False
answer
True
question
To use a predefined function, the program must include the appropriate header file. Select one: True False
answer
True
question
Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly. Select one: True False
answer
True
question
It is legal to use a return statement without any value in a user-defined void function. Select one: True False
answer
True
question
The number of reference parameters in the function heading must be less than the number of value parameters. Select one: True False
answer
False
question
Any parameter that receives a value and also sends a value outside the function must be declared as a reference parameter. Select one: True False
answer
True
question
A global identifier is an identifier declared outside of every function definition. Select one: True False
answer
True
question
Global variables have no side effects. Select one: True False
answer
False
question
By default, variables declared within a block are static variables. Select one: True False
answer
False
question
In a function with default parameters, the default parameters must be initialized to 0. Select one: True False
answer
False
question
All default parameters must be the far-right parameters of the function. Select one: True False
answer
True
question
Which of the following is a legal C++ function definition? Select one: a. void funcTest(int& u, double& v) { cout << u << " " << v << endl; } b. void funcTest(int& u, double& v); { cout << u << " " << v << endl; } c. void funcTest(int& u, double& v) ( cout << u << " " << v << endl ) d. void funcTest(int& u, double& v) [ cout << u << " " << v << endl; ]
answer
a. void funcTest(int& u, double& v) { cout << u << " " << v << endl; }
question
Consider the following definition. void funBbeta(int& one, double two) { ... } Based on this function definition, which of the following statements is valid? Select one: a. one is a value parameter and two is a reference parameter. b. one is a reference parameter and two is a value parameter. c. one and two are reference parameters. d. one and two are value parameters.
answer
b. one is a reference parameter and two is a value parameter.
question
When a function is called, the value of the ____ parameter is copied into the corresponding formal parameter. Select one: a. reference b. default c. actual d. static
answer
c. actual
question
Suppose that you have the following function. void mystery(int& one, int two) { int temp temp = one; one = two; two = temp; } What are the values of x and y after the following statements? (Assume that variables are properly declared.) x = 10; y = 15; mystery(x, y); Select one: a. x = 10; y = 10 b. x = 10; y = 15 c. x = 15; y = 10 d. x = 15; y = 15
answer
d. x = 15; y = 15
question
What is the output of the following program? #include using namespace std; void one(int x, int& y); void two(int& s, int t); int main() { int u = 1; int v = 2; one(u, v); cout << u << " " << v << endl; two(u, v); cout << u << " " << v << endl; return 0; } void one(int x, int& y) { int a; a = x; x = y; y = a; } void two(int& s, int t) { int b; b = s - t; s = t + b + 2; t = 4 * b; } Select one: a. 1 2 2 3 b. 2 2 2 3 c. 1 1 3 2 d. 1 2 1 3
answer
c. 1 1 3 2
question
What is the output of the following C++ code? int alpha = 5; int beta = 10; alpha = alpha + 5; { int alpha = 20; beta = beta + 5; } cout << alpha << " " << beta << endl; Select one: a. 10 10 b. 20 15 c. 10 15 d. 15 10
answer
c. 10 15
question
Memory for ____ variables remains allocated as long as the program executes. Select one: a. actual b. formal c. global d. local
answer
c. global