Chapter 5

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

1 1 1... and on forever

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

6

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

7

True/False: The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop

False

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

False

This is a control structure that causes a statement or group of statements to repeat.

Loop

True/ False: multiple relational expressions cannot be placed into the test condition of a for loop

True

True/False: A while loop's body can contain multiple statements, as long as they're enclosed in braces

True

True/False: It is possible to define a file stream object and open a file in one statement

True

True/False: The update expression of a for loop can contain more than one statement, e.g. counter++, total+= sales.

True

True/False: string objects have a member function named c_str that returns the contents of the object formatted as a null terminated C-string

True

This is a pre-test loop that is ideal in situations where you do not want the loop to iterate if the condition is false from the beginning.

While

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

buffer

A loop that is inside another loop is called:

nested loop

What will the following loop display? int x = 0; while (x < 5) { cout << x << endl; x++; }

0 1 2 3 4

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

20

This statement causes a loop to terminate early

Break

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

Continue

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

False

True/False: The condition that is tested by a while loop must be enclosed in parentheses and terminated with a semicolon

False

The white loop is this type of loop

Pre-test

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

Sentinel

This may be used to write information to a file.

Stream insertion operator

Assuming dataFile is a file stream object, the statement: dataFile.close();

closes a file

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

counter

This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop

for

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

fstream

This means to increase a value by one.

increment

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n):

null statement

A file must be ________ before data can be written to or read from it.

opened

The do-while loop is a(n) _____ loop that is ideal in situations where you always want the loop to iterate at least once

post-test


Kaugnay na mga set ng pag-aaral

Psychology Ch 5&6, Psychology Ch 9&10, Psy Chapter 11&12, Psy Chapter 13&14

View Set

Chapter 6 Terms: Web-based Hacking

View Set

CITI: Cultural Competence in Research, CITI Good Clinical Practice (US only Drug or Device Research)

View Set

English 4 - Chapter 4 - Nouns - Seton

View Set

Midterm Prep for CS 498: Cloud Computing Applications

View Set

Chapter 38: Caring for Clients With Cerebrovascular Disorders

View Set

King Midas Vocabulary & Review Questions

View Set