Chapter 5 Flashcards Preview

Programming Fundamentals > Chapter 5 > Flashcards

Flashcards in Chapter 5 Deck (32)
Loading flashcards...
1

to increase a value by one

increment

2

to decrease a value by one

decrement

3

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

postfix mode

4

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

prefix mode

5

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

loop header

6

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

while loop

7

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

pretest loop

8

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

infinite loop

9

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

input validation

10

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

priming read

11

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

counter

12

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

do-while loop

13

doesn't test exp until it has completed an iteration

post-test loop

14

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

user-controlled loop

15

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

for loop

16

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

running total

17

variable used to accumulate the total #s

accumulator

18

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

sentinel

19

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

output file

20

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

input file

21

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

steps to using files

22

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

sequential access (file)

23

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

random / direct access (file)

24

with what files on disk are identified by

file name

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