• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/20

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

20 Cards in this Set

  • Front
  • Back

Loop

can be used to tell a program to execute statements repeatedly




repeated executions of a block of statements

loop continuation condition

a boolean expression that controls the execution of the body





While loop

executes statements repeatedly while the condition is true




if evaluation is false, entire loop terminates




pretest loop because the continuation condition is checked before the loop body is executed

syntax for while loop

while (loop-continuation-condition) {


//loop body


Statement(s);


}

counter controlled loop

you know how many times the loop body needs to be executed because the control variable count is used to count the number of executions

infinite loops

make sure the loop continuation condition eventually becomes false so that loop will terminate

off-by-one-error

programmer often make the mistake of executing a loop one more or less time

sentinel value

signifies the end of the input

do while loop

executes the loop body first and then checks the loop continuation condition




if evaluation is true, the loop body is executed again, if it is false, the do while loop terminates




posttest loop because the condition is checked after the loop body is executed

do while loop syntax

do {


//loop body


Statement(s);


} while (loop continuation condition);

for loop

has a concise syntax for writing loops




pretest loop because the continuation condition is checked before the loop body is executed

for loop syntax

for (initial action; loop continuation condition action after each iteration) {


//loop body;


Statement(s);


}

iteration

a one time execution of a loop body




(repetition)



control variable

a for loop generally uses a variable to control how many times the loop body is executed and when the loop terminates

initial action

initializes a control variable

action after each iteration

increments or decrements the control variable

loop continuation condition in for loop

tests whether the control variable has reached a termination value

nested loop

consist of an outer loop and one or more inner loops




each time the outer loop is repeated, the inner loops are reentered and started anew

break

immediately ends the innermost loop, which contains the break

continue

ends the current iteration