Ch_5_Looping Flashcards

1
Q

Loop

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Priming Read (Priming Statement)

A

The first read operation, which takes place just before the loop. It provides the first value for the loop to test.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Update Expression

A

The third expression in a for loop that executes at the end of each iteration, before the test expression is tested again.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

++ Operator

A

Unary operator that increases an operand value by 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

– Operator

A

Unary operator that decreases an operand value by 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Prefix Mode

A

Operator placed before the variable. Causes the increment/decrement to happen before the variable is used in an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Postfix Mode

A

Operator placed after the variable. Causes the increment/decrement to happen after the variable is used in an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Counter

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Running Total

A

Sum of numbers that accumulates with each iteration of a loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Accumulator

A

The variable used to store a Running Total.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Sentinel

A

A special value that marks the end of a list of values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Sentinel Controlled Loop

A

A loop that terminates then the user enters a sentinel value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Do-While Loop

A

A post-test loop. The expression is tested after each iteration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

For Loop

A

A Pretest Loop that combines the initialization, testing, and updating of a loop control variable in a single loop header.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Two Categories of Loops

A
  • Conditional Loops
  • Count Controlled Loops
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Conditional Loop

A

Executes as long as a condition exists.

17
Q

Count Controlled Loop

A

A loop that repeats a specific number of times.

18
Q

When should the While Loop be used?

A
  • Pre Test Loop
  • When you do not want the loop to iterate if the test condition if false from the beginning.
  • Input Validation
  • When iterating over a list of data that terminates with a sentinel value.
19
Q

When should the Do-While Loop be used?

A
  • Post-Test Loop
  • When you want the loop to iterate at least once.
  • Repeating a menu.
  • Asking users if they want to repeat a set of actions.
20
Q

When should the For Loop be used?

A
  • Pre-Test Loop
  • Ideal in situations when the exact number of iterations is known.
21
Q

Break Statement

A
  • When encountered in a Loop, the loop immediately stops and the program moves to the statement immediately following the loop.
  • In a nested loop, the break statement only breaks the loop it is placed in.
22
Q

Continue Statement

A

When encountered, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration.

23
Q

Text File

A

A file that contains data that has been encoded as text, using a scheme such as ASCII or Unicode.

24
Q

Binary File

A

A file that contains data that has not been converted to text.

25
Q

Two General File Access Methods

A
  • Sequential Access
  • Direct Access
26
Q

Sequential Access File

A

You access data from the beginning to the end of the file, in sequence.

27
Q

Direct Access (Random Access)

A

You can directly access any piece of data in the file without reading the data that comes before it.

28
Q

File Stream Object

A

An object that is associated with a specific file and provides a way for the program to work with that file.

29
Q

Five steps taken when a file is used by a program

A
  1. Include the header file needed to perform file input/output
  2. Define a file stream object
  3. Open the file
  4. Use the file
  5. Close the file
30
Q

fstream Header FIle

A
  • Contains all the declarations necessary for file operations.
  • Defines the data types ofstream, ifstream, and fstream
31
Q

ofstream

A
  • Output File Stream
  • Used to create a file and write data to it.
32
Q

ifstream

A
  • Input File Stream
  • Used to open an existing file and write data to it
33
Q

fstream

A
  • File Stream
  • Used to open files for reading, writing, or both.
34
Q

cctype header file

A

-Needed to use the toupper() and tolower() functions