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;
19 Cards in this Set
- Front
- Back
What are the three types of loop statements?
|
While, do-while, and for loops
|
|
Define the following syntax:
while (loop-continuation-condition) { //Loop body Statement(s); } |
It is the syntax for a while loop
|
|
How does the do-while loop execute?
|
The do-while loop executes the loop body first, then checks the loop-continuation-condition to determine whether to continue or terminate the loop
|
|
What is a counter-controlled loop?
|
A loop that is controlled by a control variable
|
|
What is a one-time execution of a loop body referred to as?
|
An iteration of the loop
|
|
How do you "think before coding"?
|
Think how you would solve the problem without writing a program
|
|
What are the three steps to consider when writing a loop?
|
Step 1: Identify the statements that need to be repeated
Step 2: Wrap these statements in a loop like this: while (true) { Statements; } Step 3: Code the loop-continuation-condition and add appropriate statements for controlling the loop |
|
What is a sentinel-controlled loop?
|
A loop that uses a sentinel value to control it's execution
|
|
What is a sentinel value?
|
A special input value that signifies the end of a loop
|
|
How does the while loop execute?
|
The while loop repeatedly executes the statements in the loop body when the loop-continuation-condition evaluates to true
|
|
Define the following syntax:
do { //Loop body Statement(s); while (loop-continuation-condition); |
It is the syntax for the do-while loop
|
|
When is it best to use a do-while loop versus a while loop?
|
Use the do-while loop if you have statements inside the loop that must be executed at least once
|
|
Define the following syntax:
for (initial-action; loop-continuation-condition; action-after-each-iteration) { //Loop body; Statement(s); } |
It is the syntax for the for loop
|
|
How does the for loop execute?
|
A for loop performs an initial action once, then repeatedly executes the statements in the loop body, and performs an action after an iteration when the loop-continuation-condition evaluates to true
|
|
What is a control variable?
|
A variable that controls how many times the loop body is executed and when the loop terminates
|
|
What are some for loop variations?
|
|
|
What is a pretest loop?
|
The while loop and for loop are called pretest loop because the continuation condition is checked before the loop body is executed
|
|
What is a posttest loop?
|
The do-while loop is called a posttest loop because the condition is checked after the loop body is executed
|
|
What is a nested loop?
|
Nested loops consist of an outer loop and one or more inner loops
|