Loops in C: for, while, break, and continue

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

1/21

flashcard set

Earn XP

Description and Tags

Comprehensive vocabulary flashcards reviewing fundamental loop structures, execution flow, control statements, and common errors in C programming.

22 Terms

1
New cards

Loop

A programming structure that repeatedly executes a block of code as long as a specified condition remains true.

2
New cards

Loop Body

The block of repeated statements located between braces inside a loop.

3
New cards

Iteration

A single complete execution of a loop body.

4
New cards

Loop Counter

A variable dedicated to tracking and counting the number of iterations executed by a loop.

5
New cards

Initialization (Loop)

The initial step in a loop construct that assigns the starting value to the loop counter, executed only once before any iteration begins.

6
New cards

Update Expression

The statement executed during or after each iteration that modifies the loop counter (e.g., i++i\text{++} or i–i\text{--}) to make progress toward terminating the loop.

7
New cards

Condition (in C)

An expression evaluated to determine loop continuation, where a value of 00 represents false and any non-zero value represents true.

8
New cards

Infinite Loop

A loop whose condition never evaluates to false—often due to an omitted or incorrect update—causing the loop to execute indefinitely until externally stopped.

9
New cards

Pre-test Loop

A loop type (such as forfor or whilewhile) that evaluates its controlling condition before executing the body, running zero times if the condition is initially false.

10
New cards

Post-test Loop

A loop type (such as do−whiledo-while) that executes its body first before evaluating the condition, guaranteeing that the body runs at least once.

11
New cards

for Loop

A loop structure that consolidates initialization, condition checking, and counter update into a single header, best suited when the number of iterations is known in advance.

12
New cards

while Loop

A pre-test loop construct that repeats its body as long as its condition remains true, typically chosen when the total iteration count is unknown beforehand.

13
New cards

do-while Loop

A post-test loop construct that executes the body first and tests the condition at the end, requiring a mandatory semicolon after the closing parenthesis (while (condition);while\,(condition);).

14
New cards

Sentinel Value

A designated special input value (such as 00 or −1-1) used to signal the end of data entry and terminate a condition-controlled loop without being processed as valid data.

15
New cards

break Statement

A jump statement that causes an immediate exit from the innermost loop (or switchswitch) currently executing, bypassing the remaining body statements and update steps.

16
New cards

continue Statement

A jump statement that halts the current iteration of a loop and moves execution directly to the next iteration (resuming at the update in a forfor loop, or at the condition in a whilewhile loop).

17
New cards

Off-by-One Error

A logic error that occurs when a loop executes one time too many or one time too few, commonly caused by confusing relational operators such as << and ≤\le.

18
New cards

Nested Loop

A loop enclosed inside the body of another loop, where the complete inner loop executes from start to finish for each single iteration of the outer loop.

19
New cards

Flag Variable

A variable (commonly storing 00 or 11) used to indicate whether a specific event or condition, such as finding a target element in a search, has occurred.

20
New cards

Postfix Increment (i++i\text{++})

An operator that yields the current value of the variable in an expression first, and then increments the variable by 11.

21
New cards

Prefix Increment (++i\text{++}i)

An operator that increments the variable by 11 first, and then yields the resulting value for use in the expression.

22
New cards

scanf_s

A security-enhanced standard input function used in Visual Studio that prevents buffer overflows by requiring explicit buffer sizes for character and string conversions, returning the number of successfully assigned inputs.