True/False Problems (Cos 132)

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

T

A CPU really only understands instructions that are written in machine language.

F

A For loop is somewhat limited, because the counter can only be incremented by one each time through the loop.

T

A block of code can be nested.

F

A function's return data type must be the same as the function's parameter(s).

F

A local variable and a global variable may not have the same name within the same program.

T

A parameter is a local variable that is declared inside the parentheses of a function definition.

T

A pointer can be used as a function parameter, giving the function access to the original argument.

T

A reference parameter is implemented as a local variable in the called function.

F

A stack frame is created for all invoked functions except main().

T

A static variable that is defined within a function is initialized only once, the first time the function is called.

T

A vector object automatically expands in size to accomodate the items stored in it.

F

A while loop is somewhat limited, because the counter can only be incremented by one each time through the loop.

T

An individual array element can be processed like any other type of C++ variable.

T

An initialization expression may be omitted from the for loop if no initialization is required.

T

An ofstream variable can be initialized to the name of an existing file.

T

An unseeded rand() function will return a pseudo random number.

F

Arithmetic operators that share the same precedence have right to left associativity.

F

Array names are NOT Pointer constants.

F

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;

F

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;

T

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;

F

Before you can perform a selection sort, the data must be stored in ascending order.

T

Both of the following if statements perform the same operation. if (sales > 10000) commissionRate = 0.15; if (sales > 10000) commissionRate = 0.15;

T

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.

T

Floating point constants(e.g., 29.6) are stored in memory as doubles.

F

Given float ch = 3.05f, (int)ch and ch(int) produces different outputs

T

If an array is partially initialized, the uninitialized elements will be set to zero.

T

If an integer array is partially initialized, the uninitialized elements will be set to zero.

F

If the sub-expression on the left side of an && operator is true, the expression on the right side will not be checked.

T

If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked.

F

If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error.

F

If you do not follow a consistent programming style, your programs will generate compiler errors.

F

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.

F

In C++, it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.

T

In C++, key words are written in all lowercase letters.

F

In programming, the terms "line" and "statement" always mean the same thing.

T

It is legal to subtract a pointer variable from another pointer variable.

T

It is possible to define a file stream object and open a file in one statement.

F

Local variables are initialized to zero by default.

F

Pseudocode is a form of program statement that will always evaluate to "false."

T

String objects have a member function named c_str that returns the contents of the object formatted as a null-terminated C-string.

F

The C++ language requires that you give variables names that indicate what the variables are used for.

T

The amount of memory used by an array depends upon the array's data type and the number of elements in the array.

F

The ampersand (&) is used to dereference a pointer variable in C++.

F

The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order.

F

The cin << statement will stop reading input when it encounters a newline character.

T

The cin >> statement will stop reading input when it encounters a nuewline character.

F

The cin.ignore() member function can only be used to skip over 1 character.

F

The code " if(-50) " would cause a compiler error.

F

The condition that is tested by a while loop must be enclosed in parentheses and terminated with a semicolon.

F

The fixed manipulator causes a number to be displayed in scientific notation.

F

The following code correctly determines whether x contains a value in the range of 0 through 100. if (x>= && <= 100)

F

The following code correctly determines whether x contains a value in the range of 0 through 100. if (x >= 0 && <= 100)

T

The following two expressions are identical: X||Y&&Z __________________ X||(Y&&Z)

F

The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions.

F

The length() string member function counts the terminating null character.

T

The number of comparisons made by a binary search in worst case is expressed in powers of two.

T

The number of comparisons made by a binary search is expressed in powers of two.

T

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.

T

The open function invoked through an ifstream variable must be passed the name of an existing file.

F

The preprocessor executes after the compiler.

F

The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.

T

The value of an arithmetic expression will be of the same type as its most precise operand.

F

Two dimensional arrays can be passed to function, but the row size MUST be specified in the definition of the parameter variable.

F

Use of an unseeded rand() function returns a pure random number sequence.

F

Using a binary search, you are more likely to find an item than if you use a linear search.

F

When a function is called, flow of control moves to the function's prototype.

F

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

T

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.

T

When you pass an array as an argument to a function, the function can modify the contents of the array.

F

When you pass an array as an argument to a function, the function will create a local copy of the array.

F

With pointer variables you can access, but you cannot modify, data in other variables.

F

You may not nest a while loop inside a For loop.

F

You may not use the break and continue statements within nested loop syntax.

T

You should be careful when using the equality operator to compare floating point values because of potential round-off errors.

F

int array[index] is equivalent to *(array + index + sizeof(int) )

F

int num[ ] = {2, 8, -5, 7, 9 }; *num == num[1]; will evaluate to TRUE

F

push_back(value); will insert value into the vector and hence right shift all the elements in the vector by 1 unit.

F

vector<int>list2(list1); on execution will create a vector list1 as a copy of already initialized vector list2

F

'C' and "C" are the same. Both of them can be assigned to a char variable.

T

'\n' would be stored internally using a single byte.

F

*ptr += 4; adds 4 to the address stored in ptr.


Set pelajaran terkait

e commerce chapter 4 marketing on web

View Set

alluvial fan: landform created where a mountain stream suddenly flows onto flatter land and deposits its sediments • cave: underground hole or cavern eroded by groundwater • delta: triangular landform created where a river empties into a body of still wat

View Set

6.12.3 Find Configuration Information 1

View Set