1/24
Vocabulary flashcards covering loops, increment/decrement operators, file I/O operations, and loop control statements from Chapter 5.
Increment Operator (++)
An operator that adds one to a variable (e.g., val++ is the same as val=val+1). It can be used before (prefix) or after (postfix) a variable.
Decrement Operator (−−)
An operator that subtracts one from a variable (e.g., val−− is the same as val=val−1). It can be used before (prefix) or after (postfix) a variable.
Prefix Mode
A mode in which the increment or decrement operator appears before the variable (++val, −−val), causing the operator to increment or decrement first, then return the value of the variable.
Postfix Mode
A mode in which the increment or decrement operator appears after the variable (val++, val−−), causing the operator to return the value of the variable first, then increment or decrement it.
Loop
A control structure that causes a statement or statements to repeat.
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.
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.
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.
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.
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.
Running Total
An accumulated sum of numbers that is calculated across repetitions of a loop.
Accumulator
A variable that holds the running total and must be initialized (usually to 0) before entering the loop.
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.
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.
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.
for Loop
A pretest loop designed specifically for counter-controlled repetition, providing built-in expressions for initialization, testing, and updating within its header.
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.
fstream Header
The C++ header file required for accessing file stream classes and performing file operations.
ifstream
A C++ file stream data type used to handle input from a file.
ofstream
A C++ file stream data type used to handle output to a file.
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.
close Member Function
A function that disconnects a file from a file stream object and flushes any remaining buffered data to the file.
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.
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.
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.