C# & Unity: While and Do-While Loops Study Guide

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

1/17

flashcard set

Earn XP

Description and Tags

Comprehensive vocabulary flashcards covering while loops, do-while loops, loop structure, compiler errors, and debugging concepts for C# and Unity.

18 Terms

1
New cards

while loop

A loop that repeats its body while the condition is true and checks the condition before running the body.

2
New cards

do-while loop

A loop that runs its body first, then checks the condition. Its last line is } while (condition);

3
New cards

condition

The true or false question located inside the parentheses after while.

4
New cards

set, check, change

The three essential components of a loop: a starting value set before the loop, the condition that checks/reads it, and the update line that changes it.

5
New cards

update line

The line inside the loop body that modifies the value that the condition reads.

6
New cards

pass

One complete execution or run of the loop body.

7
New cards

check

One evaluation of the loop condition; if true, the body runs; if false, the loop ends.

8
New cards

zero-pass case

A while loop whose condition evaluates to false the very first time, resulting in the body executing 0 times.

9
New cards

one-pass minimum

The operational rule that a do-while loop always executes its body at least 1 time before checking the condition.

10
New cards

infinite loop

A loop that never terminates, causing the Unity editor to freeze; in class projects, the visualizer halts it at 200 passes and displays NEVER ENDED.

11
New cards

guard

A second test joined to the loop condition with && (such as && guard < 5) that terminates the loop after a specified number of passes.

12
New cards

GUARD lamp

An indicator lamp in the visualizer that is lit when the guard terminates the loop and dark when the loop condition terminates it.

13
New cards

verdict

An if / else structure placed after a loop that reports why the loop stopped executing.

14
New cards

Random.Range(1, 7)

A Unity C# method that returns 1, 2, 3, 4, 5, or 6; the upper boundary number never comes out.

15
New cards

Warning CS0642

A yellow compiler warning generated when a semicolon is accidentally placed directly after while (condition); which can cause Unity to freeze.

16
New cards

Error CS1002

A red compiler error stating '; expected', caused by omitting the required semicolon at the end of a do-while statement: } while (condition);

17
New cards

Error CS0103

A red compiler error triggered when a loop counter variable is declared inside the body (e.g., int count = 0;) rather than before the loop.

18
New cards

LoopVisualizer.Pass(…)

A visualizer method that must be placed inside the loop body as the last line, rather than outside after the closing brace.