C++ Flashcards
The job of the _______ is to fetch instructions, carry out the operations commanded by the instructions, and produce some outcome or resultant information
CPU
computers can do many different jobs because they can be ?
Programmed
Internally, the CPU consists of the _______ and the ______
Arithmetic Logic Unit and Control Unit
A _______ is an example of a secondary storage
Disk
The two general categories of software are ______ and _____
System Software and Application Software
A program is a set of _________
instructions
Since computers can’t be programmed in natural language, algorithms must be writer in a ____________ language
Programmable language
________ us the only language computers really process
machine language
_______________ languages are close to the level of humans in terms of readability
high level
____________ languages are close to the level of the computer
low level
A program’s ability to run on several different types of computers is called ______________
Portability
Words that have special meaning in a programming language are called
key words
Words of names defined by the programmer are called _________
programmer defined symbols
____________ are characters or symbols that perform operations on one or more operands
operators
___________ characters or symbols mark the beginning or ending of programming statements, or separate items in a list.
punctuation
the rules that must be followed when constructing a program are called
syntax
_______ is a named storage location
variable
A variable must be ________ before it can be used in a program
defined
the three primary activities of a program are _______, _______, and ______.
input, processing, output
_______ is the information a program gathers from the outside world
input
_____ is information a program sends to the outside world
output
A ______ is a diagram that graphically illustrates the structure of a program
hierarchy chart
Every complete statement ends with a ______
semicolon
which of the following statements is correct?
include
Every C++ program must have a function _____
main
Preprocessor directives begin with a _____.
#
A group of statements, such as the contents of a function, is enclosed in ______ .
Braces { }
Which of the following statements are not valid in cout statements?
all couts need cout <;
The negation operator is ____
Unary
An _____ is like a variable, but its value is read only and cannot be changed during the programs execution
named Constant
When to processor directives execute?
Before the compiler compiles your program
A variable must be defined before it can be used?
True
Variable names may begin with a number?
False
Variable names may be up to 31 characters long?
True
A left brace in a C++ program should always be followed by a right brace later in the program
True
You cannot initialize a named constant that is declared with the const modifier
False
An expression using the greater than, less than, greater than or equal to, less than or equal to, equal, or not equal to operator is called a _____ expression
relational
A relational expression is either ______ or ________.
true or false
The if statement regards an expression with the value 0 as ______
False
The if statement regard an expression with a nonzero value as ______.
True
For an if statement to conditionally execute a group of statements, the statement must be enclosed in a set of _________.
Braces
In an if/else statement, the if past executes its statement or block if the expression is _______, and else part executes its statement or block if the expression is ________.
true, false
The trailing else is an if/else statement that has a similar purposed as the _______ section of a switch statement
default
The if / else statement is actually a form of the _____ statement
nested
If the sub-expression on the left of the _____ logical operator is false. The right sub-expression is not checked.
&& And
If the sub-expression on the left of an ______ logical operator is true, the right sub-expression is not checked.
|| Or
The ______ logical operator has higher precedence than the other logical operators.
! Net
The logical operators have _______ associativity
left to right
The ________ logical operator works best when testing a number to determine if it is within a range
&& And
The _______ logical operator works best when testing a number to determine if it is outside a range.
|| Or
A variable with ______ scope is only visible when the program is executing in the block containing the variables definition
block
You use the ________ operator to determine whether one string object is greater then another string object.
> Greater
An expression using the ________ operator is called an conditional expression
conditional
The expression that is tested by a switch statement must have an _____ value
interger
The expression following a case statement must be an _____.
integer constant
A program will “Fall through” a case section if it is missing the _____ statement
Break
The = operator and the == operator perform the same expression when used in a Boolean expression?
False
A variable defined in an inner block may not have the same name as a variable defined in the outer block?
false
A conditionally executed statement should be indented one level from the if statement?
True
All lines in a block should be indented one level?
True
It’s safe to assume that all uninitialized variable automatically start with 0 as their value?
False
When an if statement is nested in the part if part of another statement, the only time the inner if is executed is when the expression of the outer if is true?
True
When an if statement is nested in the else part of another statement, as in an if else if, the only time the inner if is executed is when the expression of the other if is true?
False
The scope of a variable is limited to the block in which it is defined
True
You can use relational operators to compare string objects
True
x ! = y is the same as (x>y || x<y) ?
True
y= y ?
False
x>=y is the same as (x>y && x=y) ?
False
To ______ a value means to increase it by one and to _____ a value means to decrease it by one?
increment, decrement
When the increment or decrement operator is place before the operand ( or to the operands left) the operator is being used in the ____mode?
prefix
When the increment or decrement operator is placed after the operand ( or to the operands right), the operand is being used in the ______ mode.
postfix
The statement of clock that is repeated is known as the _______ of the loop
body
Each repetition of a loop is known as a ________.
iteration
A loop that evaluates its test expression before each repetition is an ____ loop
pretest
A loop that evaluates its test expression after each repetition is an ______ loop
posttest
A loop that does not have a way of stopping is called an ________ loop
infinite or endless
A __________ is a variable that counts the number of times a loop repeats
counter
A ______ is a sum of numbers that accumulated with each iteration of a loop
running total
A _________ is a variable that is initialized to some starting value, usually zero, and then has numbers added to it in each iteration of a loop
accumulator
A _________ is a special value that marks the end of a series of values
sentinel
The _______ loop is always iterates at least once
do while
The ______ and _______ loops will not iterate at all if their test expressions are false to start with
while and for
The ____ loop is ideal for situations that require a counter
for
Inside the for loop’s parentheses, the first expression is the _______, the second expression is the _________, and the third expression is the ________.
initialization, test, update
A loop that is inside another loop is called a ________ loop
nested
The ___________ statement causes a loop to terminate immediately
break
The _______ statement causes a loop to skip the running statements in the current iteration
continue
The operand of the increment and the decrement operators can be any valid mathematical expression.
false
The while loop is a pretest loop?
true
The do while loop is a post test loop
false
It is not necessary to initialize counter variable ?
False
All three of the for loops expressions may be omitted ?
true
One limitation of the for loop is that only one variable is that only one variable may be initialized in the initialization expression?
False
Variables may be defined inside the body of a loop
True
A variable may be defined inside the body of a loop
True
A variable may be defined in the initialization expression of the loop
True
In a nested loop, the outer loop executes faster then the inner loop?
False
In a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loop ?
True
To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops?
False
The break statement causes a loop to stop the current iteration and begin the next one ?
False
The continue statement causes a terminated loop to resume?
False
In a nested loop, the break statement only interrupts the loop it is placed in.
True
When you call an ofstream object’s member function, the specified file will be erased if it already exists?
True
The ______ is the part of a function definition that shows the function name, return type, and parameter list?
header
If a function doesn’t return a value, the word ____ will appear as its return type?
void
Either a functions _____ or it’s _____ must precede all calls to the function?
definition, prototype
Values that are sent into a function are called ______ .
arguments
Special variables that hold copies of function argument are called _____.
parameters
When only a copy of an argument is passed to a function, it is said to be passed by ______.
Value
A _____ eliminates the need to place a function definition before all calls to the function.
prototype
A ______ variable is defined inside a function and is not accessible outside the function.
local
_____ variables are defined outside all functions and are accessible to any function within their scope
global
_____ variables provide an easy way to share large amounts of data among all the functions in a program.
global
Unless you explicitly initialize global variables, they are automatically initialized to _______.
Zero
If a function had a local variable with the same name as a global variable, only the _____ variable can be seen by the function.
local
______ local variables retain their value between function calls
static
The _____ statement causes a function to end immediately
return
______ arguments are passed to parameters automatically if no argument is provided in the function call
default
When a function uses a mixture of parameters with and without default arguments, the parameters with default arguments must be defined
last
The value of a default argument must be a _______.
constant
When used as parameters, ______ variables allow a function to access the parameters original argument.
reference
Reference variables are defined like regular variables, except there is an ______ in front of the name.
&
The _____ function causes a program to terminate
exit
Two or more functions may have the same name as long as their _____ are different
parameter lists
Functions should be given names that reflect their purpose?
True
Function headers are terminated with a semicolon?
False
Function prototypes are terminated with a semicolon ?
True
If other functions are defined before the main, the program still starts executing at the main function?
True
When a function terminates, it always branches back to the main, regardless where it was called from?
False
Arguments are passed to the function parameters in the order they appear in the function call?
True
The scope of the parameter is limited to the function which uses it?
True
Changes to a function parameter always affect the original arguments as well?
False
In a function prototype, the names of the parameter variables may be left out?
True
Many functions may have local variables with the same name?
True
Overuse of global variables can lead to problems?
True
Static local variables are not destroyed when a function returns?
True
All static variables are initialized to -1 by default?
False
Initialization of static local variables only happen once, regardless of how many times the function in which they are defined is called?
True
When a function with default arguments is called an argument is left out, all arguments that come after it must be left out as well?
True
It is not possible for a function to have some parameters with default arguments and some without?
False
The exit function can only be called from the main?
False
A stub is a dummy function that is called instead of the actual function it represents?
True
The ____ indicated the number of elements, or values, an array can hold?
Size declarator
The size declamatory must be an ______ with a value greater than _____.
integer, 0
The element of an array is accessed and indexed by a number known as a ______.
subscript
Subscript numbering in C++ always starts _____.
Zero
The number inside the brackets of an array definition is the ____. But the number inside the arrays brackets in an assignment statement, or any other statement that works with the contents of the array is the ____.
size declarator, subscript
C++ has no array ________ checking, which means you can inadvertently store data past the end of an array.
bounds
Starting values for an array may be specified with ______ list.
Initialization
If an array is partially initialized the uninitialized elements will be set to _______.
Zero
If the size declamatory of an array definition is omitted, C++ counts the number of times in the _______ to determine how large the array should be.
initialization list
By using the same _______ for multiple arrays, you can build relationships between the data stored in the arrays
subscripts
You cannot use the ______ operator to copy data from one array to another array in a single statement
Assignment =
Any time the name of an array is used without brackets and a subscript, it is seen as ______.
an address
To pass an array to a function, pass the _______ of the array.
address, or name
An _____ array is like several arrays of the same type put together
multi-dimensional
It is best to think of a two dimensional array as having ____ and _____.
rows, columns
To define a two dimensional array, _____ size declarators are required
two
When initializing a two dimensional array, it helps to enclose each rows initialization list in ______.
braces
When two dimensional array is passed to a function the ________ size must be specified.
column
The _____ is a collection of programmer defined data types and algorithms that you may use in your programs.
Standard Template Library (or STL)
The two types of containers defined by the STL are _____ and _____.
Sequence and associative
The vector data type is an _____ container
sequence
To define a vector in your program, you must #include the ______ header file.
Vector
To store a value in a vector that does not have a starting size, or that is already fill, use the ______ member function.
push_back
To determine the number of elements in a vector, use the _____ member function.
size
Use the ______ member function to remove the last element from a vector.
pop_back
To completely clear the contents of a vector, use the ____ member function.
clear
An array’s size declarator can be either a literal, named constant, or a variable?
False
To calculate the amount of memory used by an array, multiply the number of elements by the number of bytes each element uses?
True
The individual elements of an array are accessed and indexed by unique numbers?
True
The first element in an array is accessed by the subscript 1?
False
The subscript of the last element in an single dimensional array is one less then the total number of elements in the array?
True
The contents of an array element cannot be displayed with cout?
False
Subscript numbers may be stored in variables?
True
You can write program that use invalid subscripts for an array?
True
Arrays can not be initialized when they are defined. A loop of other means must be used?
False
The values in an initialization list are stored in the array in the order they appear in the list?
True
C++ allows you to partially initialize and array?
True
If an array is partially initialized, the uninitialized elements will contain “garbage”?
False
If you leave an element uninitialized, you do not have to leave all the ones that follow it uninitialized?
False
If you leave out the size of the declarator of an array definition, you do not have to include the initialization list
False
The uninitialized elements of a string array will automatically be set to the value of 0?
False
You cannot use the assignment operator to copy one array’s contents to another in a single statement?
True
When an array name used without brackets and a subscript, it is seen as the value of the first element in the array?
False
To pass an array to a function, pass the name of the array?
True
When defining a parameter variable to hold a single dimensional array argument, you do not have to include the size declarator.
True
When an array is passed to a function, the function has access to the original array?
True
A two dimensional array is like several identical arrays put together?
True
It’s best to think of 2D arrays as having rows and columns?
True
The first size declarator (in the declaration of a 2D array) represents the number of columns. The second size definition represents the number of rows?
False
2D arrays may be passed to functions, but the row size must be specified in the definition of the parameter variable?
False
C++ allows you to create arrays with three or more dimensions?
True
A vector is an associative container?
False
To use a vector, you must include the vector header file?
True
Vectors can report the number of elements they contain?
True
You can use the [ ] operator to insert a value into a vector that has no elements?
False
If you add a value to a vector that is already full, the vector will automatically increase its size to accommodate the new value?
True