Chapter 5: Control Structures II (Repetition)

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/26

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering key loop concepts and terms from the lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

27 Terms

1
New cards

while loop

A pretest loop that evaluates its condition before each iteration and executes the body while the condition is true.

2
New cards

for loop

A counted loop that combines initialization, condition, and update in one construct; iterates a defined number of times.

3
New cards

do…while loop

A posttest loop that executes its body at least once, then tests the condition to determine if another iteration should occur.

4
New cards

loop control variable (LCV)

The variable that controls how many times a loop executes (e.g., i).

5
New cards

counter-controlled loop

A loop where a counter determines the number of iterations and is updated each time.

6
New cards

sentinel-controlled loop

A loop that ends when a designated sentinel value is encountered in input.

7
New cards

flag-controlled loop

A loop that uses a boolean flag variable to control when the loop should stop.

8
New cards

EOF-controlled loop

A loop that uses end-of-file status to determine when to stop, often via input streams like cin.

9
New cards

end-of-file (EOF)

A condition indicating no more input data is available.

10
New cards

eof function

A member function of an input stream (e.g., cin) that checks whether EOF has been reached.

11
New cards

break statement

Immediately exits the innermost loop or switch statement.

12
New cards

continue statement

Skips the remaining statements in the current iteration and proceeds to the next iteration.

13
New cards

nested control structures

Control structures (loops/conditionals) placed inside another control structure.

14
New cards

loop invariant

A property that remains true before and after every iteration, useful for debugging loops.

15
New cards

infinite loop

A loop that never terminates because the exit condition remains true.

16
New cards

patch (software patch)

A small modification added to fix a bug, often addressing symptoms rather than root cause.

17
New cards

debugging loops

The process of finding and fixing errors in loops, often using invariants and careful tracing.

18
New cards

pretest loop

A loop in which the condition is tested before the loop body (examples: while, for).

19
New cards

posttest loop

A loop in which the body is executed before the condition is tested (example: do…while).

20
New cards

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).

21
New cards

rand function

A function in cstdlib that generates pseudo-random integers; used for random numbers.

22
New cards

rand() % 100

A common technique to convert a random number into the range 0–99 by taking modulo 100.

23
New cards

cin

The standard input stream in C++, used to read data from the user or a file.

24
New cards

Windows console EOF marker (Ctrl+Z)

The keyboard sequence used to signal EOF in a Windows console.

25
New cards

logical expression in while statements

A boolean expression (often using operators like &&, ||, !) that controls loop continuation.

26
New cards

semantic error

A logic error where the code is syntactically valid but produces incorrect results.

27
New cards

do…while loop guarantee

The loop body executes at least once, regardless of the condition.