Study Set for C++ Finals

¡Supera tus tareas y exámenes ahora con Quizwiz!

Of the following, which is a valid C++ identifier?

All of the above are valid identifiers.

This vector function returns true if the vector has no elements.

Empty

"32X" refers to the storage capacity of CD-ROM's.

False

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

False

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

False

Before you can perform a bubble sort, the data must be stored in descending order.

False

You may not use the break and continue statements within the same set of nested loops.

False

This is a collection of statements that performs a specific task.

Function

What does the following statement do? vector v(10);

It creates a vector object with a starting size of 10.

Chose the TWO popular PDA platforms available today: (Select 2)

Palm Windows Mobile

Look at the following statement. bookList[2].publisher[3] = 't'; This statement:

will store the character 't' in the fourth element of the publisher member of booklist[2]

Which statement is equivalent to the following?

x*=2

When a relational expression is false, it has the value ________.

zero

These operators connect two or more relational expressions into one, or reverse the logic of an expression.

logical

The ________ is automatically appended to a character array when it is initialized with a string constant.

null terminator

This is a special value that marks the end of a list of values.

sentinel

A two-dimensional array is like ________ put together.

several identical arrays

What is the output of the following code segment? n = 1; for ( ; n <= 5; ) cout << n << ' '; n++;

1 1 1 ... and on forever

Given the following function definition void calc (int a, int& b) { int c; c = a + 2; a = a * 3; b = c + a; } What is the output of the following code fragment that invokes calc? (All variables are of type int) x = 1; y = 2; z = 3; calc(x, y); cout << x << " " << y << " " << z << endl;

1 6 3

Which line in the following program contains a call to the showDub function? 1 #include 2 using namespace std; 3 4 void showDub(int); 5 6 int main( ) 7 { 8 int x = 2; 9 10 showDub(x); 11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 }

10

How many elements does the following array have? int bugs[1000];

1000

What is the output of the following segment of code if 4 is input by the user when asked to enter a number? int num; int total = 0; cout << "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 4: total = total + 3; case 8: total = total + 6; default: total = total + 4; }

13

How many characters does the string, "John Doe" require so it can be stored in memory properly?

9

int number; cin >> number; if (number > 10 && number < 100) cout << "That number is acceptable.\n"; else cout << "That number is not acceptable.\n";

99

Look at the following statement. while (x++ < 10) Which operator is used first?

<

If a computer advertisement mentions that this machine comes with an Intel 975 chipset, what are they referring to?

A particular "traffic-director" chip(s) on the motherboard

Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.

False

An array initialization list must be placed on one single line.

False

Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement. array1 = array2;

False

C++ limits the number of array dimensions to two.

False

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

False

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

False

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

False

Local variables are initialized to zero by default.

False

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

False

The default section is required in a switch statement.

False

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

False

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

False

The preprocessor executes after the compiler.

False

The statement double money[25.00]; is a valid C++ array definition.

False

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

False

You may nest while and do-while loops, but you may not nest for loops.

False

Which of the following terms are NOT associated with RAM? (Choose all that apply)

ISA, USB, DPI

Floating point constants are normally stored in memory as doubles.

True

Global variables are initialized to zero by default.

True

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

True

In the average case, an item is just as likely to be found near the beginning of an array as near the end.

True

It is not considered good programming practice to declare all of your variables globally.

True

It is possible for a function to have some parameters with default arguments and some without.

True

Multiple relational expressions cannot be placed into the test condition of a for loop.

True

When typing in your source code into the computer, you must be very careful since most of your C++ instructions, header files, and variable names are case sensitive.

True

Data that is sorted in ascending order is ordered:

from lowest to highest value

To allow file access in a program, you must #include this header file.

fstream

To read data from a file, you define an object of this data type.

ifstream

An array with no elements is:

illegal in C++

The statement int grades[ ] = { 100, 90, 99, 80}; shows an example of

implicit array sizing

A(n) ________ can be used to specify the starting values of an array.

initialization list

When a program lets the user know that an invalid choice has been made, this is known as:

input validation

Which of the following is a valid C++ array definition?

int scores [10];

It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3].

legal in C++

When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression.

parentheses

A statement that starts with a # is called a:

preprocessor directive

Whereas < is called a relational operator, x < y is called a(n) ________.

relational expression

A two-dimensional array can be viewed as ________ and ________.

rows, columns

The ________ of a variable is limited to the block in which it is declared.

scope

The ________ sort usually performs fewer exchanges than the ________ sort.

selection, bubble

This is used to mark the end of a complete C++ programming statement.

semicolon

When the final value of an expression is assigned to a variable, it will be converted to:

the data type of the variable

An array can store a group of values, but the values must be:

the same data type

Which statement correctly defines a vector object for holding integers?

vector v;

Character constants in C++ are always enclosed in ________.

'single quotation marks'

What is the output of the following program? # include using namespace std; void doSomething(int&); int main( ) { int x = 2; cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int& num) { num = 0; cout << num << endl; }

2 0 0

How many times will the following loop display "Hello"? for (int i = 20; i > 0; i--) cout << "Hello!" << endl;

20

What will be the value of result after the following code has been executed? int a = 60; int b = 15; int result = 10; if (a = b) result image= 2;

20

Using a linear search to find a value that is stored in the last element of an array of 20,000 elements, ________ element(s) must be compared.

20,000

The total number of digits that appear before and after the decimal point is sometimes referred to as:

B and C

What will the following segment of code output? score = 40; if (score > 95) cout << "Congratulations!\n"; cout << "That's a high score!\n"; cout << "This is a test question!" << endl;

That's a high score! This is a test question!

A CD-RW drive can record information to a CD-R disc.

True

A preprocessor directive does not require a semicolon at the end.

True

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

True

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

True

A while loop's body can contain multiple statements, as long as they are enclosed in braces.

True

Suppose you are ready to set up a network in your house so that every computer can access the DSL Internet that you are already paying for. One of the first items you should purchase is a ____, whose job is to transmit the Internet "through the air."

Wireless Access Point / Wireless Router

Which character signifies the beginning of an escape sequence?

\

When writing functions that accept multi-dimensional arrays as arguments, ________ must be explicitly stated in the parameter list.

all but the first dimension

Unlike regular variables, these can hold multiple values.

arrays

In C++ the = operator indicates:

assignment

The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed:

at least once

Subscript numbering in C++

begins with zero

A(n) ________ search is more efficient than a(n) ________ search

binary, linear

An array that will hold 5 names with 20 characters in the name would be declared using which statement?

char names[5][21];

If you are reading data from a keyboard and you wanted the computer to recognize the space, tab, or Enter key as the delimiter to separate two input values, you would use the ________ object.

cin

The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

cin object

For every opening brace in a C++ program, there must be a:

closing brace

When using the sqrt function you must include this header file.

cmath

An array's size declarator must be a(n)________ with a value greater than ________.

constant integer expression, zero

nt number = 10; number += 5; number -= 2; number image= 3;

15

All data travels throughout your computer in the form of electrical "on" and "off" signals called bits.

2

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;

4.0

Regardless of the algorithm being used, a search through an array is always performed:

None of these

________ algorithms are used to arrange random data into some order.

Sorting

What is the value stored at x, given the statements:? int x; x = 3 / static_cast(4.5 + 6.4);

0

Which of the following are two popular standards used for Wireless Networking? (select two)

Bluetooth Wi-Fi (802.11)

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

False

A variable called "average" should be declared as an integer data type because it will probably hold data that contains decimal places.

False

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

False

You may not use the break statement in a nested loop.

False

You must furnish an argument with a function call.

False

Escape sequences are always stored internally as a single character.

True

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

True

What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (x) cout << "true" << endl; else cout << "false" << endl;

false

A(n) ________ search uses a loop to sequentially step through an array.

linear

This vector function is used to insert an item into a vector.

push_back

Given the following declaration, where is 77 stored in the scores array? int scores[ ]={83, 62, 77, 97};

scores [2]

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

True

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

True

If a function does not have a prototype, default arguments may be specified in the function ________.

header

Which statement allows you to properly check the char variable code to determine whether it is equal to a "C" and then output "This is a check" and then advance to a new line?

if (code == 'C') cout << "This is a check\n";

A binary search begins with the ________ element of an array.

middle

When an if statement is placed within the conditionally-executed code of another if statement, this is known as:

nesting

Array elements must be ________ before a binary search can be performed.

sorted

The value in this type of local variable persists between function calls.

static

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

True

The ________ is adequate for searching through small arrays.

linear search

One reason for using functions is to break programs into manageable units, or modules

True

In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, cookies; what is the value of cookies after the execution of the statement?

2

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

False

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

False

Software engineering is a field that encompasses designing, writing, testing, debugging, documenting, modifying, and maintaining computer programs.

True

What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl

6

What will the following code display? int number = 6; ++number; cout << number << endl;

7

Which line in the following program will cause a compiler error? 1 #include 2 using namespace std; 3 4 int main( ) 5 { 6 const int MY_VAL = 77; 7 MY_VAL = 99; 8 cout << MY_VAL << endl; 9 return 0; 10 }

7

In a function header, you must furnish:

All of these

Which of these is NOT a company which makes IBM/PC compatible computers?

Apple

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

False

Which of the categories of computers is considered to be the most powerful? These computers are usually used to handle very complex tasks.

Supercomputers

The housing for the computer. The "Case". It is available in Desktop or Tower form.

System Unit

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

True

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

True

You may use the exit( ) function to terminate a program, regardless of which control mechanism is executing.

True

________ represent storage locations in the computer's memory.

Variables

All of the above are valid identifiers.

elements

The character array company[12] can hold:

eleven characters and the null terminator

This function causes a program to terminate, regardless of which function or control mechanism is executing.

exit( )

What is the value of the following expression? true && false

false

These are used to declare variables that can hold real numbers.

floating point data types

An array can easily be stepped through by using a:

for Loop

An array can easily be stepped through by using a:

for loop

Something within a while loop must eventually cause the condition to become false, or a(n) ________ results.

infinite loop

Look at the following function prototype. int myFunction(double); What is the data type of the funtion's return value?

int

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.

trailing else

What is the value of the following expression? true && true

true

A for statement contains three expressions: initialization, test, and:

update

What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl;

0

What will the following program segment display? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } cout << funny << " " << serious << endl;

1 1

Most microcomputer systems today are essentially made up of approximately ___ parts.

15

Which one of the following would be an illegal variable name?

3dGraph

What is the last legal subscript that can be used with the following array? int values[5];

4

What is the output of the following program? # include using namespace std; void showDub(int); int main( ) { int x = 2; showDub(x); cout << x << endl; return 0; } void showDub(int num) { cout << (num image 2) << endl; }

4 2

What will the value of x be after the following statements execute? int x; x = 18.0 / 4;

4.5

A file ________ is a small holding section of memory that file-bound information is first written to.

Buffer

Which of these is the original optical, read-only storage medium? Hint: It holds up to 700MB.

CD-ROM

What part of the computer executes instructions for processing? Hint: "The Brain"

CPU

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

True

As a rule of style, when writing an if statement you should indent the conditionally-executed statements.

True

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

True

This statement may be used to stop a loop's current iteration and begin the next one.

continue

This is a variable that is regularly incremented or decremented each time a loop iterates.

counter

When an array is sorted from highest to lowest, it is said to be in ________ order.

descending

Before a structure can be used, it must be:

declared

These types of arguments are passed to parameters automatically if no argument is provided in the function call.

default

You must have a ________ for every variable you intend to use in a program.

definition

The name of an array stores the ________ of the first array element.

memory address

Which statement is equivalent to the following? number += 1;

number = number + 1

If a function is called more than once in a program, the values stored in the function's local variables do not ________ between function calls.

persist

This vector function removes an item from a vector.

pop_back

The do-while loop is considered a(n) ________ loop.

post-test

The advantage of a linear search is its:

simplicity

By using the same ________ you can build relationships between data stored in two or more arrays.

subscript

An element of a two-dimensional array is referred to by ________ followed by ________.

the row subscript of the element, the column subscript of the element


Conjuntos de estudio relacionados

Chapter 12 Vocab Child development

View Set

European absolutism practice test (60 questions) 1-4

View Set

North Carolina Insurance Laws and Rules

View Set

Magoosh Text Completion Practice

View Set

National Electrical Code. (NEC) Article 342, 344, 348, 350, 352, 356. Types of Conduits.

View Set

Chapters 29/30/31 Art History Quiz

View Set

Chapter 21: Caring for Clients with Lower Respiratory Disorders

View Set

Chapter 1. The Cycles of the Sky

View Set

Smooth muscle is nonstriated involuntary muscle

View Set