Chapter 5 Flashcards

(32 cards)

1
Q

to increase a value by one

A

increment

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

to decrease a value by one

A

decrement

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

operator is placed after the variable; matters when using operator in expression (will change value after expression executes)

A

postfix mode

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

operator is placed before the variable; matters when using operator in expression (will change value before expression executes)

A

prefix mode

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

consists of key word for loop followed by an exp enclosed in () / braces for body of loop

A

loop header

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

exp in () is tested; if it’s true, statement is executed; then exp is tested again; if true, statement is executed; cycle repeates until exp is false; is a pretest loop

A

while loop

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

tests its exp before each iteration; loop will never iterate if test exp is false to start

A

pretest loop

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

continues to repeat until program is interrupted; possible to create by accident by placing semicolon at end of loop header (disconnects body from loop) or by not updating test condition

A

infinite loop

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

process of inspecting data given to program by user and deting if it’s valid; while loop is good for this

A

input validation

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

read operation that takes place just before loop; provides the first value for the loop to test; subsequent values are obtained by the loop

A

priming read

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

variable that is regularly updated in each iteration of the loop; keeps track of the number of iterations loop has performed; set variable equal to starting value and create loop where variable is than another value and update the variable

A

counter

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

looks like an inverted while loop; must be terminated w/a semicolon; always performs at least one iteration, even if exp is false to start; is a post-test loop; should use when you want to make sure loop executes at least once (as in w/ menus); while cond is located at closing brace

A

do-while loop

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

doesn’t test exp until it has completed an iteration

A

post-test loop

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

allows user to decide number of iterations (via sentinel value or entering number into control variable)

A

user-controlled loop

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

type of loop specifically designed to initialize, test, and update a counter variable; first step is initialization exp, then second exp is tested (controls execution of loop and will repeat body of loop as long as exp is true), then third exp updates counter at end of each iteration; is a pretest loop

A

for loop

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

sum of #s that accumulates with each iteration of a loop; requires 1) loop that reads in each # in the series and 2) variable that accumulates total # of #s as they are read

A

running total

17
Q

variable used to accumulate the total #s

18
Q

special value that can’t be mistaken as a member of the list and signals that there are no more values to be entered; when user enters it, loop terminates (set while loop != to sentinel value); will not be included in running total

19
Q

file data is written to; program stores __ in it;

20
Q

file that data is read from; when a piece of data is read from a file, it’s copied from file into a variable in RAM; prgm gets __ from it

21
Q

1) file must be opened
2) file is processed
3) file must be closed

A

steps to using files

22
Q

accesses data from beginning of file to end of file; you have to read all data that comes before piece of data you want to access

A

sequential access (file)

23
Q

can jump directly to any piece of data in file w/out reading data that comes before it

A

random / direct access (file)

24
Q

with what files on disk are identified by

25
object associated with specific file; provides a way for program to work with that file
file stream object
26
output file stream; used when you want to write data to file
ofstream
27
input file stream, used when you want to open an existing file and read data from it
ifstream
28
file stream; used when you want to open files for reading, writing, or both
fstream
29
small holding section of memory that file bound data is first written to
file buffer
30
marks location of next byte that will be read from file; when you open file, its ___ is first byte in file and as data's read from file, its __ moves forward toward end of file; read position is at end of newline after 1st read
read position
31
interrupts loop it's placed in or ; interrupts program
break statement
32
causes current iteration of loop to end immediately; when encountered, all the statements in body of loop that appear after it are ignored and loop prepares for next iteration; update still occurs in for loop; in others, test exp is evaluated
continue statement