Chapter 5: Loops and Files

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/24

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering loops, increment/decrement operators, file I/O operations, and loop control statements from Chapter 5.

25 Terms

1
New cards

Increment Operator (++++)

An operator that adds one to a variable (e.g., val++val++ is the same as val=val+1val = val + 1). It can be used before (prefix) or after (postfix) a variable.

2
New cards

Decrement Operator (−−--)

An operator that subtracts one from a variable (e.g., val−−val-- is the same as val=val−1val = val - 1). It can be used before (prefix) or after (postfix) a variable.

3
New cards

Prefix Mode

A mode in which the increment or decrement operator appears before the variable (++val++val, −−val--val), causing the operator to increment or decrement first, then return the value of the variable.

4
New cards

Postfix Mode

A mode in which the increment or decrement operator appears after the variable (val++val++, val−−val--), causing the operator to return the value of the variable first, then increment or decrement it.

5
New cards

Loop

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

6
New cards

while Loop

A conditional pretest loop that evaluates an expression and repeatedly executes a statement or block of statements as long as the expression evaluates to true.

7
New cards

Pretest Loop

A type of loop where the test expression is evaluated before any iteration takes place. If the condition is false initially, the loop body never executes.

8
New cards

Infinite Loop

A loop that does not contain code to make its test expression become false, causing it to repeat an infinite number of times without stopping.

9
New cards

Input Validation

The process of inspecting data given to the program as input and determining whether it is valid, often using a while loop to reject invalid entries and repeat until valid data is entered.

10
New cards

Counter

A variable that is incremented or decremented each time a loop repeats, used to control execution of the loop; also known as the loop control variable.

11
New cards

Running Total

An accumulated sum of numbers that is calculated across repetitions of a loop.

12
New cards

Accumulator

A variable that holds the running total and must be initialized (usually to 00) before entering the loop.

13
New cards

Sentinel

A special value in a list of values that indicates the end of data; it cannot be confused with a valid value and terminates input when the number of values is unknown.

14
New cards

do-while Loop

A conditional posttest loop that executes its statement or block once before testing the expression, continuing as long as the expression remains true. A semicolon is required after the test expression.

15
New cards

Posttest Loop

A loop structure where the loop body is executed first and the test expression is evaluated afterward, guaranteeing that the loop executes at least once.

16
New cards

for Loop

A pretest loop designed specifically for counter-controlled repetition, providing built-in expressions for initialization, testing, and updating within its header.

17
New cards

Nested Loop

A loop placed entirely inside the body of another loop. The inner loop goes through all its repetitions for each single repetition of the outer loop.

18
New cards

fstream Header

The C++ header file required for accessing file stream classes and performing file operations.

19
New cards

ifstream

A C++ file stream data type used to handle input from a file.

20
New cards

ofstream

A C++ file stream data type used to handle output to a file.

21
New cards

open Member Function

A function called on a file stream object to create a link between an external file name and the internal file stream object.

22
New cards

close Member Function

A function that disconnects a file from a file stream object and flushes any remaining buffered data to the file.

23
New cards

c_str Member Function

A string member function that returns the contents of a string object formatted as a null-terminated C-string, required by the open function prior to C++ 11.

24
New cards

break Statement

A statement that prematurely terminates the execution of a loop; when used inside an inner loop, it terminates only that inner loop and returns execution to the outer loop.

25
New cards

continue Statement

A statement that causes a loop to skip the remainder of the current iteration and immediately jump to the end of the loop to prepare for the next repetition.