Quiz 6 Flashcards
If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
A) True B) False
False
In C++, a function prototype is the function heading without the body of the function.:
A) True
B) False
True
In creating C++ functions, you must be concerned with the function itself and how it interacts with other functions, such as main().
A) True
B) False
True
Calling a function places a certain amount of overhead on a computer.
A) True B) False
True
The output of the statement:
cout «_space;pow(2.0, pow(3.0, 1.0)) «_space;endl;
is ____.
A) 6.0
B) 7.0
C) 8.0
D) 9.0
8.0
The output of the statement: cout «_space;pow(3.0, 2.0) + 5 «_space;endl; is ____.
Question options:
A) 11.0
B) 12.0
C) 13.0
D) 14.0
14.0
What value is returned by the following return statement?
int x = 5;
return x + 1;
A) 0
B) 5
C) 6
D) 7
6
The standard header file for the abs(x)function is ____.
Question options:
A) <cmath></cmath>
B) <ioinput></ioinput>
C) <cctype></cctype>
D) <cstdlib></cstdlib>
A) <cmath></cmath>
Given the following function prototype:
int test(float, char);
which of the following statements is valid?
A) cout «_space;test(12, &);
B) cout «_space;test(“12.0”, ‘&’);
C) int u = test(5.0, ‘*’);
D) cout «_space;test(‘12’, ‘&’);
C) int u = test(5.0, ‘*’);
Given the function prototype:
float test(int, int, int);
which of the following statements is legal?
A) cout «_space;test(7, test(14, 23));
B) cout «_space;test(test(7, 14), 23);
C) cout «_space;test(14, 23);
D) cout «_space;test(7, 14, 23);
D) cout «_space;test(7, 14, 23);
Which statement below about prototypes and headers is true?
Question options:
A) Parameter names must be listed in the prototype, but not necessarily in the header.
B) Prototypes end with a semicolon, but headers do not.
C) Headers should come before prototypes.
D) Headers end with a semicolon, but prototypes do not.
B) Prototypes end with a semicolon, but headers do not.
Functions that do not have a return type are called ____ functions.
A) zero
B) null
C) void
D) empty
void
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 «_space;strange(4, 5) «_space;endl;
A) -1
B) 1
C) 9
D) 20
-1
Given the following function prototype:
int myFunc(int, int);
which of the following statements is valid? Assume that all variables are properly declared.
Question options:
A) cin»_space; myFunc(y);
B)cout«myFunc(myFunc(7, 8), 15);
C) cin»_space; myFunc(‘2’, ‘3’);
D) cout «myFunc(myFunc(7), 15);
B)cout«myFunc(myFunc(7, 8), 15);
The following return statement returns the value 10.
return 10, 16;
A) True B) False
False
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.
A) True B) False
True
You should make all your variables global if possible.
A) True
B) False
False
In C++, a function is allowed to change the contents of variables declared in other functions.
A) True
B) False
False
The statement: return 37, y, 2 * 3; returns the value ____.
A) 2
B) 3
C) y
D) 6
6
Given the function prototype:
double testAlpha(int u, char v, double t);
which of the following statements is legal?
A) cout «_space;testAlpha(5, ‘A’, 2);
B) cout «_space;testAlpha( int 5, char ‘A’, int 2);
C) cout «_space;testAlpha(‘5.0’, ‘A’, ‘2.0’);
D) cout «_space;testAlpha(5.0, “65”, 2.0);
A) cout «_space;testAlpha(5, ‘A’, 2);
A variable or expression listed in a call to a function is called the ____.
A) formal parameter
B) actual parameter
C) data type
D) type of the function
B) actual parameter
A variable listed in a header is known as a(n) ____ parameter.
A) actual
B) local
C) formal
D) function
C) formal
A function prototype is ____.
A) a definition, but not a declaration
B) a declaration and a definition
C) a declaration, but not a definition
D) a comment line
C) a declaration, but not a definition
The data type of a variable in a return statement must match the function type.
A) True B) False
True
The following function heading in a C++ program is valid:
int funcExp(int u, char v, float g)
A) True B) False
True