1/156
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
________ are C++ operators that change their operands by one.
++ and —
True/False: To decrement a number means to increase its value.
False
The ++ operator (3 part)
A) is a unary operator.
B) adds one to the value of its operand.
C) can operate in prefix or postfix mode.
What will the following code print?
num = 8;
cout << --num << " ";
cout << num++ << " ";
cout << num;
7 7 8
The while loop has two important parts: a condition that is tested and a statement or block of statements that is _________
epeated as long as the condition is true
True/False: The block of code in the body of a while statement can contain an unlimited number of statements, provided they are enclosed in a set of braces.
True
True/False: A while loop may have a semicolon after the test expression and before the body of the loop, but it is not required.
False
True/False: A while loop is somewhat limited, because the counter can only count up, not down.
False
The while loop is a(n) ________ loop, whereas the do-while loop is a(n) ________ loop.
pretest, post test
The statements in the body of a do-while loop are executed
at least once
A sentinel is a special value that
marks the end of a list of values
A for statement contains three expressions: initialization, test, and
update
In a for statement, the ________ expression is executed only once
initialization
True/False: An initialization expression may be omitted from the for loop if no initialization is required
True
You may define a(n) ________ in the initialization expression of a for loop.
Variable
True/False: When a loop is nested inside another loop, the outer loop goes through all its iterations for each iteration of the inner loop
False
A variable that keeps a running total of data values is called a(n)
Accumulator
For data validation, it is best to use a(n)
while loop
To use files in a C++ program you must include the ________ header file
fstream
To use an output file in a C++ program you must
1.) create a file stream object that will "point to" (i.e. reference) the file.
2.) open the file.
To ________ a value means to increase it.
increment
The -- operator
A) is a unary operator.
B) subtracts one from the value of its operand.
C) must have a value, such as a variable, as its operand.
D) can be used in either prefix or postfix mode.
What will the following code print?
num = 5;
cout << num++ << " ";
cout << num-- << " ";
cout << --num;
5 6 4
The while loop has two important parts: a condition that is tested and a statement or block of statements that is executed
as long as the condition is true
If nothing within a while loop ever causes the condition to become false, a(n) ________ may occur.
infinite loop
True/False: A while loop is somewhat limited because the counter can only be incremented or decremented by one each time through the loop.
False
A(n) ________ is a variable that controls the number of times a loop iterates.
loop control variable
A(n) ________ is a variable that is regularly incremented or decremented each time a loop iterates.
counter
True/False: When a loop is nested inside another loop, the inner loop goes through all its iterations for each iteration of the outer loop.
True
A(n) ________ is a special value that marks the end of a list of values.
sentinel
The do-while loop is a(n) ________ loop, whereas the while loop is a(n) ________ loop.
post test, pretest
True/False: You can nest a for loop inside another for loop, but cannot nest a while loop inside another while loop or a do-while loop inside another do-while loop
False
The statements in the body of a do-while loop are executed
at least once
True/False: Before beginning to add value to it, an accumulator should be initialized to 1.
False
The ________ statement causes a loop to terminate early.
break
If a while loop has no braces around the body of the loop
the loop body contains just one statement
The ideal type of loop to use if you want a user to enter exactly 20 values is a(n) ________ loop.
for
The ideal type of loop to use for repeating a menu is a(n) ________ loop
do-while
To use files in a C++ program you must include the ________ header file
fstream
In order for a C++ program to read data from a file
A) the file must already exist.
B) the program must define a file stream object that can "point to" (i.e., reference) the file.
C) the program must open the file.
Breaking a program up into a set of manageable sized functions is called ________ programming
modular
A function ________ includes the statements that make up the function
definition
A function other than the main function is executed
whenever it is called
True/False: A function can have zero to many parameters and either zero or one return value(s)
True
In a function header, in addition to the name of the function, you are required to furnish
A) a data type for each parameter.
B) an identifier name for each parameter.
C) the data type of the return value
In a function prototype, in addition to the name of the function, you are required to furnish
A) a data type for each parameter.
B) the data type of the return value.
In a function call, in addition to the name of the function, you are required to furnish
an identifier name or constant for each argument.
A void function is one that
returns no value.
True/False: Functions are ideal for use in menu-drive programs. When a user selects a menu item, the program can call an appropriate function to carry out the user's choice
True
A ________ variable is defined inside the body of a function and is not accessible outside that function.
local
The value in ________ local variable is retained between function calls.
A static
True/False: When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.
True
When used as a parameter, a ________ variable allows a function to access and modify the original argument passed to it
reference
True/False: It is possible for a function to have some parameters with default arguments and some
without.
True
Two or more functions may have the same name provided that
their parameter lists are different
When more than one function has the same name they are called ________ functions
overloaded
The ________ statement causes a function to end and the flow of control to move back to the point where the function call was made.
return
True/False: A function with a return type of bool must return a value of either true or false.
True
The ________ function causes the entire program to terminate, regardless of which function or control mechanism is executing
exit()
A ________ is a program module whose purpose is to test other modules by calling them
driver
True/False: One reason for using functions is to break programs into a set of manageable units, or modules.
True
A function ________ is a statement that causes a function to execute
call
A void function is one that
returns no value
True/False: If a function has no return statement, the flow of control moves to the next function in the file when the closing brace of the function body is reached.
False
A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information.
argument, parameter
A function can have ________ parameters, and it can have either zero or one return value(s)
zero to many
True/False: When you make a function call, the order of the arguments you send does not matter as long as the number of arguments matches the number of parameters the function has
False
When only a copy of an argument is passed to a function, it is said to be passed
by value
When a function needs access to an original argument passed to it, for example in order to change its value, the argument needs to be
passed into a reference parameter
A function ________ eliminates the need to place the function definition before all calls to the function
prototype
A ________ variable is declared outside all functions.
global
In the following statement, what is 22.0?
cout << sqrt(22.0);
An argument
True/False: Although global variables can be useful, it is considered good programming practice to
restrict your use of them
True
True/False: Both function headers and function calls must list the data types of all data being passed to the function
False
A(n) ________ argument is one that is automatically passed to a parameter when the argument is left out of the function call.
default
True/False: In C++ global and local numeric variables are initialized to zero by default.
FalseA static local variable is one
A static local variable is one
whose value is retained between function calls
An overloaded function is one
that has the same name as another function.
True/False: You may use the exit() function to return the flow of control from a function back to main() regardless of where the function was called from.
False
A ________ is a dummy function that is called instead of the actual function it represents, to test that the call to and return from the function are working correctly.
stub
True/False: Object-oriented programming is centered around objects that include both data and the functions that operate on them.
True
True/False: ADT stands for Algorithmic Data Type
False
Which of the following statements about ADTs are true.
A) They specify the values the data type can hold.
B) They specify the operations the data type can perform.
C) They hide the details of how the data type is implemented
True/False: A class declaration provides a pattern for creating objects, but doesn’t make any objects.
True
An object typically hides its data, but allows outside code to access it through its
public member functions
In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________.
attributes, methods
When three different objects of a class are created, they are said to be separate ________ of the class.
instances
When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.
inline
True/False: A constructor is a public class function that is automatically invoked (i.e., called) whenever a class object is created
True
True/False: A class must have exactly one constructor.
False
A constructor may have a return type of
None
A constructor that does not require that any arguments be passed to it is called a(n) ________ constructor.
default
A destructor is a member function that
is automatically called when an object is destroyed
A(n) ________ member function may be called by a statement in a function that is outside of the class.
public
A C++ member function that uses, but does not change, the value of a member variable is called
an accessor
Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions.
get, set
If Circle is the name of a class, which of the following statements would create a Circle object named myCircle?
Circle myCircle;
If setRadius is a Circle class function and myCircle is a Circle object, which of the following statements would set myCircle's radius to 2.5?
myCircle.setRadius(2.5);
True/False: A structure has member variables, like an object, but they are usually all public and accessed directly with the dot operator, instead of by calling member functions.
True
True/False: An Abstract data type (ADT) is a programmer-defined data type that specifies the values the type can hold, the operations that can be performed on them, and how the operations will be implemented.
False