1/26
Vocabulary flashcards covering key loop concepts and terms from the lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
while loop
A pretest loop that evaluates its condition before each iteration and executes the body while the condition is true.
for loop
A counted loop that combines initialization, condition, and update in one construct; iterates a defined number of times.
do…while loop
A posttest loop that executes its body at least once, then tests the condition to determine if another iteration should occur.
loop control variable (LCV)
The variable that controls how many times a loop executes (e.g., i).
counter-controlled loop
A loop where a counter determines the number of iterations and is updated each time.
sentinel-controlled loop
A loop that ends when a designated sentinel value is encountered in input.
flag-controlled loop
A loop that uses a boolean flag variable to control when the loop should stop.
EOF-controlled loop
A loop that uses end-of-file status to determine when to stop, often via input streams like cin.
end-of-file (EOF)
A condition indicating no more input data is available.
eof function
A member function of an input stream (e.g., cin) that checks whether EOF has been reached.
break statement
Immediately exits the innermost loop or switch statement.
continue statement
Skips the remaining statements in the current iteration and proceeds to the next iteration.
nested control structures
Control structures (loops/conditionals) placed inside another control structure.
loop invariant
A property that remains true before and after every iteration, useful for debugging loops.
infinite loop
A loop that never terminates because the exit condition remains true.
patch (software patch)
A small modification added to fix a bug, often addressing symptoms rather than root cause.
debugging loops
The process of finding and fixing errors in loops, often using invariants and careful tracing.
pretest loop
A loop in which the condition is tested before the loop body (examples: while, for).
posttest loop
A loop in which the body is executed before the condition is tested (example: do…while).
Fibonacci sequence
A sequence where each term is the sum of the two previous terms; nth term is a(n)=a(n-1)+a(n-2).
rand function
A function in cstdlib that generates pseudo-random integers; used for random numbers.
rand() % 100
A common technique to convert a random number into the range 0–99 by taking modulo 100.
cin
The standard input stream in C++, used to read data from the user or a file.
Windows console EOF marker (Ctrl+Z)
The keyboard sequence used to signal EOF in a Windows console.
logical expression in while statements
A boolean expression (often using operators like &&, ||, !) that controls loop continuation.
semantic error
A logic error where the code is syntactically valid but produces incorrect results.
do…while loop guarantee
The loop body executes at least once, regardless of the condition.