True/False Problems – Flashcards

Unlock all answers in this set

Unlock answers
question
T
answer
A CPU really only understands instructions that are written in machine language.
question
F
answer
If you do not follow a consistent programming style, your programs will generate compiler errors.
question
F
answer
The C++ language requires that you give variables names that indicate what the variables are used for.
question
F
answer
The fixed manipulator causes a number to be displayed in scientific notation.
question
T
answer
When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point.
question
F
answer
Use of an unseeded rand() function returns a pure random number sequence.
question
F
answer
In programming, the terms "line" and "statement" always mean the same thing.
question
F
answer
The length() string member function counts the terminating null character.
question
F
answer
The preprocessor executes after the compiler.
question
F
answer
The cin.ignore() member function can only be used to skip over 1 character.
question
F
answer
If you want to know the length of the string that is stored in a string object, you can call the object's size member function.
question
T
answer
The only difference between the get function and the >> operator is that get reads the first character typed, even if it is a space, tab, or the [Enter] key.
question
F
answer
The cin << statement will stop reading input when it encounters a newline character.
question
F
answer
Given float ch = 3.05f, (int)ch and ch(int) produces different outputs
question
F
answer
Arithmetic operators that share the same precedence have right to left associativity.
question
T
answer
In C++, key words are written in all lowercase letters.
question
F
answer
The preprocessor executes after the compiler.
question
F
answer
Pseudocode is a form of program statement that will always evaluate to "false."
question
F
answer
In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.
question
F
answer
If you do not follow a consistent programming style, your programs will generate compiler errors.
question
T
answer
Floating point constants(e.g., 29.6) are stored in memory as doubles.
question
T
answer
'n' would be stored internally using a single byte.
question
F
answer
When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.
question
T
answer
The value of an arithmetic expression will be of the same type as its most precise operand.
question
T
answer
The cin >> statement will stop reading input when it encounters a nuewline character.
question
T
answer
An unseeded rand() function will return a pseudo random number.
question
F
answer
If the sub-expression on the left side of an && operator is true, the expression on the right side will not be checked.
question
F
answer
The following code correctly determines whether x contains a value in the range of 0 through 100. if (x>= && <= 100)
question
F
answer
'C' and "C" are the same. Both of them can be assigned to a char variable.
question
T
answer
The following two expressions are identical: X||Y&&Z __________________ X||(Y&&Z)
question
T
answer
If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked.
question
T
answer
Both of the following if statements perform the same operation. if (sales > 10000) commissionRate = 0.15; if (sales > 10000) commissionRate = 0.15;
question
T
answer
You should be careful when using the equality operator to compare floating point values because of potential round-off errors.
question
F
answer
The following code correctly determines whether x contains a value in the range of 0 through 100. if (x >= 0 && <= 100)
question
F
answer
The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions.
question
F
answer
A For loop is somewhat limited, because the counter can only be incremented by one each time through the loop.
question
F
answer
The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.
question
F
answer
You may not use the break and continue statements within nested loop syntax.
question
F
answer
The condition that is tested by a while loop must be enclosed in parentheses and terminated with a semicolon.
question
F
answer
You may not nest a while loop inside a For loop.
question
T
answer
It is possible to define a file stream object and open a file in one statement.
question
F
answer
When a function is called, flow of control moves to the function's prototype.
question
T
answer
A static variable that is defined within a function is initialized only once, the first time the function is called.
question
F
answer
A function's return data type must be the same as the function's parameter(s).
question
F
answer
Local variables are initialized to zero by default.
question
T
answer
A block of code can be nested.
question
F
answer
A function's return data type must be the same as the function's parameter(s).
question
T
answer
An ofstream variable can be initialized to the name of an existing file.
question
F
answer
A while loop is somewhat limited, because the counter can only be incremented by one each time through the loop.
question
T
answer
A reference parameter is implemented as a local variable in the called function.
question
T
answer
It is possible to define a file stream object and open a file in one statement.
question
F
answer
A local variable and a global variable may not have the same name within the same program.
question
T
answer
A static variable that is defined within a function is initialized only once, the first time the function is called.
question
T
answer
A parameter is a local variable that is declared inside the parentheses of a function definition.
question
F
answer
The code " if(-50) " would cause a compiler error.
question
T
answer
An initialization expression may be omitted from the for loop if no initialization is required.
question
F
answer
A stack frame is created for all invoked functions except main().
question
T
answer
The open function invoked through an ifstream variable must be passed the name of an existing file.
question
F
answer
When a function is called, flow of control moves to the function's prototype.
question
T
answer
String objects have a member function named c_str that returns the contents of the object formatted as a null-terminated C-string.
question
T
answer
The amount of memory used by an array depends upon the array's data type and the number of elements in the array.
question
F
answer
Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statemet. array1 = array2;
question
T
answer
When you pass an array as an argument to a function, the function can modify the contents of the array.
question
F
answer
If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error.
question
T
answer
If an integer array is partially initialized, the uninitialized elements will be set to zero.
question
T
answer
A vector object automatically expands in size to accomodate the items stored in it.
question
T
answer
The number of comparisons made by a binary search in worst case is expressed in powers of two.
question
F
answer
With pointer variables you can access, but you cannot modify, data in other variables.
question
F
answer
Two dimensional arrays can be passed to function, but the row size MUST be specified in the definition of the parameter variable.
question
F
answer
push_back(value); will insert value into the vector and hence right shift all the elements in the vector by 1 unit.
question
F
answer
vectorlist2(list1); on execution will create a vector list1 as a copy of already initialized vector list2
question
F
answer
*ptr += 4; adds 4 to the address stored in ptr.
question
F
answer
int num[ ] = {2, 8, -5, 7, 9 }; *num == num[1]; will evaluate to TRUE
question
F
answer
int array[index] is equivalent to *(array + index + sizeof(int) )
question
F
answer
Array names are NOT Pointer constants.
question
F
answer
Assume array 1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement. array1 = array2;
question
F
answer
When you pass an array as an argument to a function, the function will create a local copy of the array.
question
F
answer
If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error.
question
T
answer
An individual array element can be processed like any other type of C++ variable.
question
T
answer
If an array is partially initialized, the uninitialized elements will be set to zero.
question
F
answer
The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order.
question
T
answer
The number of comparisons made by a binary search is expressed in powers of two.
question
F
answer
Before you can perform a selection sort, the data must be stored in ascending order.
question
F
answer
Using a binary search, you are more likely to find an item than if you use a linear search.
question
F
answer
With pointer variables you can access, but you cannot modify, data in other variables.
question
T
answer
It is legal to subtract a pointer variable from another pointer variable.
question
T
answer
C++ does not perform array bounds checking, making it possible for you to assign a pointer the address of an element out of the boundaries of an array.
question
T
answer
A pointer can be used as a function parameter, giving the function access to the original argument.
question
F
answer
The ampersand (&) is used to dereference a pointer variable in C++.
question
T
answer
Assuming myValues is an array of int values, and index is an int variable, both of the following statements do the same thing. cout << myValues[index] << endl; cout << *(myValues + index) << endl;
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New