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:
is an operator used for one value
unary operators
Prefix ++
Postfix ++
Prefix and postfix increment operators
++someValue and someValue++
Prefix and postfix decrement operators
–someValue and someValue–
The expression (x++) simply means______
A) add 1 to x and return the old value (Postfix increment)
B) add 1 to x and return the new value (Prefix increment)
C) take 1 from x and return the old value (Postfix decrement)
D) take 1 from x and return the new value (Prefix decrement)
A) add 1 to x and return the old value
The expression (++x) simply means______
A) add 1 to x and return the old value (Postfix increment)
B) add 1 to x and return the new value (Prefix increment)
C) take 1 from x and return the old value (Postfix decrement)
D) take 1 from x and return the new value (Prefix decrement)
B) add 1 to x and return the new value
The expression (–x) simply means______
A) add 1 to x and return the old value (Postfix increment)
B) add 1 to x and return the new value (Prefix increment)
C) take 1 from x and return the old value (Postfix decrement)
D) take 1 from x and return the new value (Prefix decrement)
D) take 1 from x and return the new value
The expression (x–) simply means______
A) add 1 to x and return the old value (Postfix increment)
B) add 1 to x and return the new value (Prefix increment)
C) take 1 from x and return the old value (Postfix decrement)
D) take 1 from x and return the new value (Prefix decrement)
C) take 1 from x and return the old value