Module 3 (Prelim) Flashcards
3.1 Overview 3.2 Loop Structure 3.3 while Loop 3.4 Increment and Decrement Operators 3.5 for Loop 3.6 do...while Loop 3.7 Nested Loops 3.8 break and continue Statements
A structure that allows repeated execution of a block of statements
Loop
A block of statements that are executed repeatedly
Loop body
One execution of any loop
Iteration
Three types of loops
while
for
do…while
The loop-controlling Boolean expression is the first statement
while
A concise format in which to execute loops
for
The loop-controlling Boolean expression is the last statement
do…while
Executes a body of statements continually. As long as the Boolean expression that controls entry into the loop continues to be true
while loop
while loop syntax:
while (expression)
….statement
Performs a task a predetermined number of times
Definite loop or counter-controlled loop
Definite loop or counter-controlled loop is also called _________
counted loop
Sentinel variable is tested in the condition. Loop ends when sentinel is encountered
Indefinite or Sentinel-controlled while loops
A loop that never ends. Can result from a mistake in the while loop
Infinite loop
Suspect an infinite loop when:
-The same output is displayed repeatedly
-The screen remains idle for an extended period of time
To exit an infinite loop:
- press and hold Ctrl + C
- Break
is an operator used for one value
unary operators